GitOps for k8s
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

change_test.go 687B

12345678910111213141516171819202122232425262728293031
  1. package v9
  2. import (
  3. "encoding/json"
  4. "reflect"
  5. "testing"
  6. "github.com/fluxcd/flux/image"
  7. )
  8. func TestChangeEncoding(t *testing.T) {
  9. ref, _ := image.ParseRef("docker.io/fluxcd/flux")
  10. name := ref.Name
  11. for _, update := range []Change{
  12. {Kind: GitChange, Source: GitUpdate{URL: "git@github.com:weaveworks/flux"}},
  13. {Kind: ImageChange, Source: ImageUpdate{Name: name}},
  14. } {
  15. bytes, err := json.Marshal(update)
  16. if err != nil {
  17. t.Fatal(err)
  18. }
  19. var update2 Change
  20. if err = json.Unmarshal(bytes, &update2); err != nil {
  21. t.Fatal(err)
  22. }
  23. if !reflect.DeepEqual(update, update2) {
  24. t.Errorf("unmarshaled != original.\nExpected: %#v\nGot: %#v", update, update2)
  25. }
  26. }
  27. }