修复相关BUG + 增加单元测试, 覆盖率100%
This commit is contained in:
32
scheme_test.go
Normal file
32
scheme_test.go
Normal file
@ -0,0 +1,32 @@
|
||||
// Package consts ...
|
||||
//
|
||||
// Description : consts ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2025-04-20 15:47
|
||||
package consts
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHttpScheme_String(t *testing.T) {
|
||||
Convey("scheme 字符串值", t, func() {
|
||||
byteData, err := json.Marshal(SchemeHTTPS)
|
||||
So(err, ShouldBeNil)
|
||||
So(SchemeHTTPS.String(), ShouldEqual, "https")
|
||||
So(string(byteData), ShouldEqual, `"https"`)
|
||||
})
|
||||
Convey("scheme MarshalJSON", t, func() {
|
||||
str, err := SchemeHTTPS.MarshalJSON()
|
||||
So(err, ShouldBeNil)
|
||||
So(string(str), ShouldEqual, `"https"`)
|
||||
dataList := []HttpScheme{SchemeHTTPS}
|
||||
jsonData, err := json.Marshal(dataList)
|
||||
So(err, ShouldBeNil)
|
||||
So(string(jsonData), ShouldEqual, `["https"]`)
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user