MCPcopy Create free account
hub / github.com/git-bug/git-bug / TestJSON

Function TestJSON

entities/identity/identity_test.go:222–246  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

220}
221
222func TestJSON(t *testing.T) {
223 repo := makeIdentityTestRepo(t)
224
225 identity, err := NewIdentity(repo, "René Descartes", "rene.descartes@example.com")
226 require.NoError(t, err)
227
228 // commit to make sure we have an Id
229 err = identity.Commit(repo)
230 require.NoError(t, err)
231 require.NotEmpty(t, identity.Id())
232
233 // serialize
234 data, err := json.Marshal(identity)
235 require.NoError(t, err)
236
237 // deserialize, got a IdentityStub with the same id
238 var i Interface
239 i, err = UnmarshalJSON(data)
240 require.NoError(t, err)
241 require.Equal(t, identity.Id(), i.Id())
242
243 // make sure we can load the identity properly
244 i, err = ReadLocal(repo, i.Id())
245 require.NoError(t, err)
246}
247
248func TestIdentityRemove(t *testing.T) {
249 repo := repository.CreateGoGitTestRepo(t, false)

Callers

nothing calls this directly

Calls 7

CommitMethod · 0.95
IdMethod · 0.95
IdMethod · 0.95
makeIdentityTestRepoFunction · 0.85
UnmarshalJSONFunction · 0.85
ReadLocalFunction · 0.85
NewIdentityFunction · 0.70

Tested by

no test coverage detected