From b8a257ea7f26a9020a358a866e297dc8446324dd Mon Sep 17 00:00:00 2001 From: Maximilien Raulic Date: Thu, 19 Dec 2024 14:27:35 +0100 Subject: [PATCH] test: add regression tests on Action JSON methods --- scm/const_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scm/const_test.go b/scm/const_test.go index 82966b101..f42c29316 100644 --- a/scm/const_test.go +++ b/scm/const_test.go @@ -25,3 +25,24 @@ func TestStateJSON(t *testing.T) { }) } } + +func TestActionJSON(t *testing.T) { + for i := ActionCreate; i < ActionCompleted; i++ { + in := i + t.Run(in.String(), func(t *testing.T) { + b, err := json.Marshal(in) + if err != nil { + t.Fatal(err) + } + + var out Action + if err := json.Unmarshal(b, &out); err != nil { + t.Fatal(err) + } + + if in != out { + t.Errorf("%s != %s", in, out) + } + }) + } +}