1package bug
 2
 3import (
 4	"encoding/json"
 5	"testing"
 6	"time"
 7
 8	"github.com/stretchr/testify/require"
 9
10	"github.com/MichaelMure/git-bug/identity"
11	"github.com/MichaelMure/git-bug/repository"
12)
13
14func TestSetStatusSerialize(t *testing.T) {
15	repo := repository.NewMockRepo()
16
17	rene, err := identity.NewIdentity(repo, "René Descartes", "rene@descartes.fr")
18	require.NoError(t, err)
19
20	unix := time.Now().Unix()
21	before := NewSetStatusOp(rene, unix, ClosedStatus)
22
23	data, err := json.Marshal(before)
24	require.NoError(t, err)
25
26	var after SetStatusOperation
27	err = json.Unmarshal(data, &after)
28	require.NoError(t, err)
29
30	// enforce creating the ID
31	before.Id()
32
33	// Replace the identity stub with the real thing
34	require.Equal(t, rene.Id(), after.Author().Id())
35	after.Author_ = rene
36
37	require.Equal(t, before, &after)
38}