33 lines
		
	
	
		
			869 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			869 B
		
	
	
	
		
			Go
		
	
	
	
	
	
// Package consts ...
 | 
						|
//
 | 
						|
// Description : consts ...
 | 
						|
//
 | 
						|
// Author : go_developer@163.com<白茶清欢>
 | 
						|
//
 | 
						|
// Date : 2025-04-20 14:22
 | 
						|
package consts
 | 
						|
 | 
						|
import (
 | 
						|
	"encoding/json"
 | 
						|
	. "github.com/smartystreets/goconvey/convey"
 | 
						|
	"testing"
 | 
						|
)
 | 
						|
 | 
						|
func TestHttpHeader_String(t *testing.T) {
 | 
						|
	Convey("http header字符串值", t, func() {
 | 
						|
		byteData, err := json.Marshal(HeaderKeyContentType)
 | 
						|
		So(err, ShouldBeNil)
 | 
						|
		So(HeaderKeyContentType.String(), ShouldEqual, "Content-Type")
 | 
						|
		So(string(byteData), ShouldEqual, `"Content-Type"`)
 | 
						|
	})
 | 
						|
	Convey("http header MarshalJSON", t, func() {
 | 
						|
		str, err := HeaderKeyContentType.MarshalJSON()
 | 
						|
		So(err, ShouldBeNil)
 | 
						|
		So(string(str), ShouldEqual, `"Content-Type"`)
 | 
						|
		dataList := []HttpHeader{HeaderKeyContentType}
 | 
						|
		jsonData, err := json.Marshal(dataList)
 | 
						|
		So(err, ShouldBeNil)
 | 
						|
		So(string(jsonData), ShouldEqual, `["Content-Type"]`)
 | 
						|
	})
 | 
						|
}
 |