// Package consts ... // // Description : consts ... // // Author : go_developer@163.com<白茶清欢> // // Date : 2025-04-20 15:17 package consts import ( "encoding/json" . "github.com/smartystreets/goconvey/convey" "testing" ) func TestFileType_String(t *testing.T) { Convey("file type 字符串值", t, func() { byteData, err := json.Marshal(FileTypeJson) So(err, ShouldBeNil) So(FileTypeJson.String(), ShouldEqual, "json") So(string(byteData), ShouldEqual, `"json"`) }) Convey("file type MarshalJSON", t, func() { str, err := FileTypeJson.MarshalJSON() So(err, ShouldBeNil) So(string(str), ShouldEqual, `"json"`) dataList := []FileType{FileTypeJson} jsonData, err := json.Marshal(dataList) So(err, ShouldBeNil) So(string(jsonData), ShouldEqual, `["json"]`) }) } func TestFileType_IsValid(t *testing.T) { Convey("file type 非法验证", t, func() { So(FileType("Invalid").IsValid(), ShouldBeFalse) }) Convey("file type 合法验证", t, func() { So(FileType("json").IsValid(), ShouldBeTrue) }) }