test: do not compare non-marshallable field, refactor
This commit is contained in:
parent
1356e0dc34
commit
4202a7bc26
@ -10,7 +10,7 @@ func TestReq(t *testing.T) {
|
|||||||
req := Req{}
|
req := Req{}
|
||||||
|
|
||||||
req.Command = ListRepos
|
req.Command = ListRepos
|
||||||
req.SetData(Job{ID: 999, RepoName: "test"})
|
req.SetData(&Job{ID: 999, RepoName: "test"})
|
||||||
|
|
||||||
bytes := req.Marshal()
|
bytes := req.Marshal()
|
||||||
|
|
||||||
@ -23,25 +23,27 @@ func TestReq(t *testing.T) {
|
|||||||
err = req2.GetData(&job)
|
err = req2.GetData(&job)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
assert.Equal(t, req2.Type, "api.Job")
|
assert.Equal(t, req2.Type, "*api.Job")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestResp(t *testing.T) {
|
func TestResp(t *testing.T) {
|
||||||
resp := Resp{}
|
resp := Resp{}
|
||||||
|
|
||||||
resp.Error = "abracadabra"
|
resp.Error = "abracadabra"
|
||||||
resp.SetData([]Repo{Repo{}, Repo{}})
|
resp.SetData(&[]Repo{{}, {}})
|
||||||
|
|
||||||
bytes := resp.Marshal()
|
bytes := resp.Marshal()
|
||||||
|
|
||||||
resp2, err := Resp{}.Unmarshal(bytes)
|
resp2, err := Resp{}.Unmarshal(bytes)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
|
resp2.Err = nil // non-marshallable
|
||||||
|
|
||||||
assert.Equal(t, resp, resp2)
|
assert.Equal(t, resp, resp2)
|
||||||
|
|
||||||
var repos []Repo
|
var repos []Repo
|
||||||
err = resp2.GetData(&repos)
|
err = resp2.GetData(&repos)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
assert.Equal(t, resp2.Type, "[]api.Repo")
|
assert.Equal(t, resp2.Type, "*[]api.Repo")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user