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") +}