From 3bf09d66c67a346b92934601dffe8af438ff708e Mon Sep 17 00:00:00 2001 From: Christopher Zell Date: Fri, 2 Dec 2022 15:36:22 +0100 Subject: [PATCH] fix: experiments need to start with lower letter Set json annotation to marshal the experiments into correct key, with small letters. --- .../chaos-experiments/chaos_experiments.go | 2 +- .../chaos-experiments/chaos_experiments_test.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/go-chaos/internal/chaos-experiments/chaos_experiments.go b/go-chaos/internal/chaos-experiments/chaos_experiments.go index 60ee02f08..0af0f6ba9 100644 --- a/go-chaos/internal/chaos-experiments/chaos_experiments.go +++ b/go-chaos/internal/chaos-experiments/chaos_experiments.go @@ -15,7 +15,7 @@ var chaosContent embed.FS const experimentFileName = "experiment.json" type Experiments struct { - Experiments []map[string]interface{} + Experiments []map[string]interface{} `json:"experiments"` } func ReadExperimentsForClusterPlan(clusterPlan string) (Experiments, error) { diff --git a/go-chaos/internal/chaos-experiments/chaos_experiments_test.go b/go-chaos/internal/chaos-experiments/chaos_experiments_test.go index 314b5a758..3a2568f13 100644 --- a/go-chaos/internal/chaos-experiments/chaos_experiments_test.go +++ b/go-chaos/internal/chaos-experiments/chaos_experiments_test.go @@ -1,6 +1,7 @@ package chaos_experiments import ( + "encoding/json" "testing" "github.com/stretchr/testify/assert" @@ -22,3 +23,17 @@ func Test_ShouldReadExperiments(t *testing.T) { assert.NotEqual(t, experimentsForClusterPlan.Experiments[0], experimentsForClusterPlan.Experiments[1]) assert.NotEqual(t, "Zeebe deployment distribution", experimentsForClusterPlan.Experiments[0]) } + +func Test_ShouldBeAbleToMarshalExperiments(t *testing.T) { + // given + + // when + experimentsForClusterPlan, err := ReadExperimentsForClusterPlan("Production - S") + + // then + marshal, err := json.Marshal(experimentsForClusterPlan) + require.NoError(t, err) + + // experiments key should be small + assert.Contains(t, string(marshal), "experiments") +}