41 lines
863 B
Go
41 lines
863 B
Go
|
package swaggerset
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
|
"os"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestSwaggerSet_1(t *testing.T) {
|
||
|
s := NewSwaggerSet()
|
||
|
data, err := os.ReadFile("swagger.yaml")
|
||
|
assert.Nil(t, err)
|
||
|
|
||
|
err = s.AddSwaggerset("localhost:8080", "service", data)
|
||
|
assert.Nil(t, err)
|
||
|
|
||
|
msgs, err := s.GetMessage(
|
||
|
"localhost:8080",
|
||
|
"service",
|
||
|
"/domain-service/v1/push_mail/enabled",
|
||
|
"POST")
|
||
|
assert.Nil(t, err)
|
||
|
assert.NotNil(t, msgs.Msgs)
|
||
|
for _, msg := range msgs.Msgs {
|
||
|
reqParam, err := json.Marshal(msg.RequestParam)
|
||
|
assert.Nil(t, err)
|
||
|
reqBody, err := json.Marshal(msg.RequestBody)
|
||
|
assert.Nil(t, err)
|
||
|
rsp, err := json.Marshal(msg.Response)
|
||
|
assert.Nil(t, err)
|
||
|
fmt.Printf("type: %s, reqParam: %s, reqBody: %s, rsp: %s \n", msg.Type, reqParam, reqBody, rsp)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestSwaggerSet_2(t *testing.T) {
|
||
|
Run4()
|
||
|
}
|