From 0c070fbadfdccd04db49fb3e2793fa3ab5521d5d Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Tue, 10 Feb 2026 23:04:59 +0100 Subject: [PATCH 1/5] test: added tests to cover theme customization in enable/stubs Signed-off-by: Frederic BIDON --- enable/stubs/colors/enable_colors_test.go | 43 +++++++++++++++++++---- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/enable/stubs/colors/enable_colors_test.go b/enable/stubs/colors/enable_colors_test.go index 9ab6391e4..609e1f625 100644 --- a/enable/stubs/colors/enable_colors_test.go +++ b/enable/stubs/colors/enable_colors_test.go @@ -4,6 +4,7 @@ package colors import ( + "fmt" "testing" target "github.com/go-openapi/testify/v2/assert" @@ -11,18 +12,48 @@ import ( ) func TestEnableColors(t *testing.T) { - t.Parallel() + // Test execution is serialized on the sensitive package initialization section + // + // Proper test coverage of Enable() is assured by the testintegration package. + for _, opt := range []Option{ + WithSanitizedTheme("light"), + WithDark(), + WithLight(), + WithTheme(ThemeDark), + } { + mock := new(mockT) + target.NotPanics(mock, func() { + testEnableWithLock(opt) // executed serially + + _ = target.JSONEq(mock, `{"hello": "world", "foo": "bar"}`, `{"hello": "worldwide", "foo": "bar"}`) + }) + // we may call several times with different options, but only the first setup is going to be used: + // colorization is set lazily with a sync.Once global by the consuming package. + t.Log(mock.errorString()) + } +} + +func testEnableWithLock(opt Option) { colorstub.Enable( func() []colorstub.Option { return []colorstub.Option{ colorstub.WithEnable(true), - colorstub.WithSanitizedTheme("light"), + opt, } }) +} + +type mockT struct { + errorFmt string + args []any +} + +func (m *mockT) Errorf(format string, args ...any) { + m.errorFmt = format + m.args = args +} - mock := new(testing.T) - target.NotPanics(mock, func() { - _ = target.JSONEq(mock, `{"hello": "world", "foo": "bar"}`, `{"hello": "worldwide", "foo": "bar"}`) - }) +func (m *mockT) errorString() string { + return fmt.Sprintf(m.errorFmt, m.args...) } From 49c455cb405111b5f7c19136d3f1b10a655cecce Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Tue, 10 Feb 2026 23:20:10 +0100 Subject: [PATCH 2/5] test(yaml): added coverage for failing YAML cases Signed-off-by: Frederic BIDON --- enable/yaml/forward_requirements_test.go | 20 ++++---- enable/yaml/requirements_test.go | 65 +++++++++++++++++------- 2 files changed, 57 insertions(+), 28 deletions(-) diff --git a/enable/yaml/forward_requirements_test.go b/enable/yaml/forward_requirements_test.go index 5d6144e7e..9c82b90d8 100644 --- a/enable/yaml/forward_requirements_test.go +++ b/enable/yaml/forward_requirements_test.go @@ -12,7 +12,7 @@ import ( func TestRequireYAMLEqWrapper_EqualYAMLString(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) mockRequire := target.New(mock) mockRequire.YAMLEq(`{"hello": "world", "foo": "bar"}`, `{"hello": "world", "foo": "bar"}`) @@ -24,7 +24,7 @@ func TestRequireYAMLEqWrapper_EqualYAMLString(t *testing.T) { func TestRequireYAMLEqWrapper_EquivalentButNotEqual(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) mockRequire := target.New(mock) mockRequire.YAMLEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) @@ -36,7 +36,7 @@ func TestRequireYAMLEqWrapper_EquivalentButNotEqual(t *testing.T) { func TestRequireYAMLEqWrapper_HashOfArraysAndHashes(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) mockRequire := target.New(mock) expected := ` @@ -74,7 +74,7 @@ array: func TestRequireYAMLEqWrapper_Array(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) mockRequire := target.New(mock) mockRequire.YAMLEq(`["foo", {"hello": "world", "nested": "hash"}]`, `["foo", {"nested": "hash", "hello": "world"}]`) @@ -86,7 +86,7 @@ func TestRequireYAMLEqWrapper_Array(t *testing.T) { func TestRequireYAMLEqWrapper_HashAndArrayNotEquivalent(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) mockRequire := target.New(mock) mockRequire.YAMLEq(`["foo", {"hello": "world", "nested": "hash"}]`, `{"foo": "bar", {"nested": "hash", "hello": "world"}}`) @@ -98,7 +98,7 @@ func TestRequireYAMLEqWrapper_HashAndArrayNotEquivalent(t *testing.T) { func TestRequireYAMLEqWrapper_HashesNotEquivalent(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) mockRequire := target.New(mock) mockRequire.YAMLEq(`{"foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) @@ -110,7 +110,7 @@ func TestRequireYAMLEqWrapper_HashesNotEquivalent(t *testing.T) { func TestRequireYAMLEqWrapper_ActualIsSimpleString(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) mockRequire := target.New(mock) mockRequire.YAMLEq(`{"foo": "bar"}`, "Simple String") @@ -122,7 +122,7 @@ func TestRequireYAMLEqWrapper_ActualIsSimpleString(t *testing.T) { func TestRequireYAMLEqWrapper_ExpectedIsSimpleString(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) mockRequire := target.New(mock) mockRequire.YAMLEq("Simple String", `{"foo": "bar", "hello": "world"}`) @@ -134,7 +134,7 @@ func TestRequireYAMLEqWrapper_ExpectedIsSimpleString(t *testing.T) { func TestRequireYAMLEqWrapper_ExpectedAndActualSimpleString(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) mockRequire := target.New(mock) mockRequire.YAMLEq("Simple String", "Simple String") @@ -146,7 +146,7 @@ func TestRequireYAMLEqWrapper_ExpectedAndActualSimpleString(t *testing.T) { func TestRequireYAMLEqWrapper_ArraysOfDifferentOrder(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) mockRequire := target.New(mock) mockRequire.YAMLEq(`["foo", {"hello": "world", "nested": "hash"}]`, `[{ "hello": "world", "nested": "hash"}, "foo"]`) diff --git a/enable/yaml/requirements_test.go b/enable/yaml/requirements_test.go index e9680f0d5..b50d71818 100644 --- a/enable/yaml/requirements_test.go +++ b/enable/yaml/requirements_test.go @@ -40,7 +40,7 @@ array: func TestRequireYAMLEq_EqualYAMLString(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) target.YAMLEq(mock, `{"hello": "world", "foo": "bar"}`, `{"hello": "world", "foo": "bar"}`) if mock.Failed { t.Error("Check should pass") @@ -50,7 +50,7 @@ func TestRequireYAMLEq_EqualYAMLString(t *testing.T) { func TestRequireYAMLEq_EquivalentButNotEqual(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) target.YAMLEq(mock, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) if mock.Failed { t.Error("Check should pass") @@ -60,7 +60,7 @@ func TestRequireYAMLEq_EquivalentButNotEqual(t *testing.T) { func TestRequireYAMLEq_HashOfArraysAndHashes(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) target.YAMLEq(mock, expectedYAML, actualYAML) if mock.Failed { t.Error("Check should pass") @@ -70,7 +70,7 @@ func TestRequireYAMLEq_HashOfArraysAndHashes(t *testing.T) { func TestRequireYAMLEq_Array(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) target.YAMLEq(mock, `["foo", {"hello": "world", "nested": "hash"}]`, `["foo", {"nested": "hash", "hello": "world"}]`) if mock.Failed { t.Error("Check should pass") @@ -80,7 +80,7 @@ func TestRequireYAMLEq_Array(t *testing.T) { func TestRequireYAMLEq_HashAndArrayNotEquivalent(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) target.YAMLEq(mock, `["foo", {"hello": "world", "nested": "hash"}]`, `{"foo": "bar", {"nested": "hash", "hello": "world"}}`) if !mock.Failed { t.Error("Check should fail") @@ -90,7 +90,7 @@ func TestRequireYAMLEq_HashAndArrayNotEquivalent(t *testing.T) { func TestRequireYAMLEq_HashesNotEquivalent(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) target.YAMLEq(mock, `{"foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) if !mock.Failed { t.Error("Check should fail") @@ -100,7 +100,7 @@ func TestRequireYAMLEq_HashesNotEquivalent(t *testing.T) { func TestRequireYAMLEq_ActualIsSimpleString(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) target.YAMLEq(mock, `{"foo": "bar"}`, "Simple String") if !mock.Failed { t.Error("Check should fail") @@ -110,7 +110,7 @@ func TestRequireYAMLEq_ActualIsSimpleString(t *testing.T) { func TestRequireYAMLEq_ExpectedIsSimpleString(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) target.YAMLEq(mock, "Simple String", `{"foo": "bar", "hello": "world"}`) if !mock.Failed { t.Error("Check should fail") @@ -120,7 +120,7 @@ func TestRequireYAMLEq_ExpectedIsSimpleString(t *testing.T) { func TestRequireYAMLEq_ExpectedAndActualSimpleString(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) target.YAMLEq(mock, "Simple String", "Simple String") if mock.Failed { t.Error("Check should pass") @@ -130,7 +130,7 @@ func TestRequireYAMLEq_ExpectedAndActualSimpleString(t *testing.T) { func TestRequireYAMLEq_ArraysOfDifferentOrder(t *testing.T) { t.Parallel() - mock := new(MockT) + mock := new(mockT) target.YAMLEq(mock, `["foo", {"hello": "world", "nested": "hash"}]`, `[{ "hello": "world", "nested": "hash"}, "foo"]`) if !mock.Failed { t.Error("Check should fail") @@ -140,28 +140,57 @@ func TestRequireYAMLEq_ArraysOfDifferentOrder(t *testing.T) { func TestRequireYAMLUnmarshalAsWrapper(t *testing.T) { t.Parallel() - mock := new(testing.T) type dummy struct { Hello string `yaml:"hello"` Foo string `yaml:"foo"` } - value := dummy{Hello: "world", Foo: "bar"} - target.YAMLUnmarshalAsT(mock, value, `{"hello": "world", "foo": "bar"}`) - target.YAMLMarshalAsT(mock, `{"hello": "world", "foo": "bar"}`, value) + t.Run("should pass", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + + value := dummy{Hello: "world", Foo: "bar"} + target.YAMLUnmarshalAsT(mock, value, `{"hello": "world", "foo": "bar"}`) + if mock.Failed { + t.Error("Check should pass") + } + + target.YAMLMarshalAsT(mock, `{"hello": "world", "foo": "bar"}`, value) + if mock.Failed { + t.Error("Check should pass") + } + }) + + t.Run("should fail", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + + value := dummy{Hello: "world", Foo: "bar"} + target.YAMLUnmarshalAsT(mock, value, `{"hello": "world", "foo": "yay"}`) + if !mock.Failed { + t.Error("Check should fail with FailNow") + } + + target.YAMLMarshalAsT(mock, `{"hello": "world", "foo": "yay"}`, value) + if !mock.Failed { + t.Error("Check should fail with FailNow") + } + }) } -type MockT struct { +type mockT struct { Failed bool } // Helper is like [testing.T.Helper] but does nothing. -func (MockT) Helper() {} +func (mockT) Helper() {} -func (t *MockT) FailNow() { +func (t *mockT) FailNow() { t.Failed = true } -func (t *MockT) Errorf(format string, args ...any) { +func (t *mockT) Errorf(format string, args ...any) { _, _ = format, args } From c926633d29a649c9993830b0e896137ddf75973f Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Wed, 11 Feb 2026 00:01:27 +0100 Subject: [PATCH 3/5] test(yaml): more missing test cases explictly covered in tests Signed-off-by: Frederic BIDON --- enable/yaml/forward_assertions_test.go | 44 ++++++++++++++ enable/yaml/forward_requirements_test.go | 56 ++++++++++++++++++ enable/yaml/requirements_test.go | 74 ++++++++++++++++++++++++ 3 files changed, 174 insertions(+) diff --git a/enable/yaml/forward_assertions_test.go b/enable/yaml/forward_assertions_test.go index b0907f9dc..5dd31c1f9 100644 --- a/enable/yaml/forward_assertions_test.go +++ b/enable/yaml/forward_assertions_test.go @@ -123,3 +123,47 @@ func TestYAMLEqWrapper_ArraysOfDifferentOrder(t *testing.T) { t.Error("YAMLEq should return false") } } + +func TestYAMLEqfWrapper(t *testing.T) { + t.Parallel() + + t.Run("should pass", func(t *testing.T) { + t.Parallel() + + assert := target.New(new(testing.T)) + if !assert.YAMLEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, yamlCheckMsg, "equivalent") { + t.Error("YAMLEqf should return true") + } + }) + + t.Run("should fail", func(t *testing.T) { + t.Parallel() + + assert := target.New(new(testing.T)) + if assert.YAMLEqf(`{"foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, yamlCheckMsg, "not equivalent") { + t.Error("YAMLEqf should return false") + } + }) +} + +func TestYAMLEqBytesfWrapper(t *testing.T) { + t.Parallel() + + t.Run("should pass", func(t *testing.T) { + t.Parallel() + + assert := target.New(new(testing.T)) + if !assert.YAMLEqBytesf([]byte(expectedYAML), []byte(actualYAML), yamlCheckMsg, "equivalent bytes") { + t.Error("YAMLEqBytesf should return true") + } + }) + + t.Run("should fail", func(t *testing.T) { + t.Parallel() + + assert := target.New(new(testing.T)) + if assert.YAMLEqBytesf([]byte(`{"foo": "bar"}`), []byte(`{"foo": "bar", "hello": "world"}`), yamlCheckMsg, "not equivalent bytes") { + t.Error("YAMLEqBytesf should return false") + } + }) +} diff --git a/enable/yaml/forward_requirements_test.go b/enable/yaml/forward_requirements_test.go index 9c82b90d8..ecccc74df 100644 --- a/enable/yaml/forward_requirements_test.go +++ b/enable/yaml/forward_requirements_test.go @@ -154,3 +154,59 @@ func TestRequireYAMLEqWrapper_ArraysOfDifferentOrder(t *testing.T) { t.Error("Check should fail") } } + +func TestRequireYAMLEqfWrapper(t *testing.T) { + t.Parallel() + + t.Run("should pass", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + mockRequire := target.New(mock) + + mockRequire.YAMLEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, yamlCheckMsg, "equivalent") + if mock.Failed { + t.Error("Check should pass") + } + }) + + t.Run("should fail", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + mockRequire := target.New(mock) + + mockRequire.YAMLEqf(`{"foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, yamlCheckMsg, "not equivalent") + if !mock.Failed { + t.Error("Check should fail") + } + }) +} + +func TestRequireYAMLEqBytesfWrapper(t *testing.T) { + t.Parallel() + + t.Run("should pass", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + mockRequire := target.New(mock) + + mockRequire.YAMLEqBytesf([]byte(expectedYAML), []byte(actualYAML), yamlCheckMsg, "equivalent bytes") + if mock.Failed { + t.Error("Check should pass") + } + }) + + t.Run("should fail", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + mockRequire := target.New(mock) + + mockRequire.YAMLEqBytesf([]byte(`{"foo": "bar"}`), []byte(`{"foo": "bar", "hello": "world"}`), yamlCheckMsg, "not equivalent bytes") + if !mock.Failed { + t.Error("Check should fail") + } + }) +} diff --git a/enable/yaml/requirements_test.go b/enable/yaml/requirements_test.go index b50d71818..b9419d359 100644 --- a/enable/yaml/requirements_test.go +++ b/enable/yaml/requirements_test.go @@ -35,6 +35,8 @@ array: - "string" - ["nested", "array", 5.5] ` + + yamlCheckMsg = "yaml check: %s" ) func TestRequireYAMLEq_EqualYAMLString(t *testing.T) { @@ -137,6 +139,78 @@ func TestRequireYAMLEq_ArraysOfDifferentOrder(t *testing.T) { } } +func TestRequireYAMLEqf(t *testing.T) { + t.Parallel() + + t.Run("should pass", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + target.YAMLEqf(mock, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, yamlCheckMsg, "equivalent") + if mock.Failed { + t.Error("Check should pass") + } + }) + + t.Run("should fail", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + target.YAMLEqf(mock, `{"foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, yamlCheckMsg, "not equivalent") + if !mock.Failed { + t.Error("Check should fail") + } + }) +} + +func TestRequireYAMLEqBytesf(t *testing.T) { + t.Parallel() + + t.Run("should pass", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + target.YAMLEqBytesf(mock, []byte(expectedYAML), []byte(actualYAML), yamlCheckMsg, "equivalent bytes") + if mock.Failed { + t.Error("Check should pass") + } + }) + + t.Run("should fail", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + target.YAMLEqBytesf(mock, []byte(`{"foo": "bar"}`), []byte(`{"foo": "bar", "hello": "world"}`), yamlCheckMsg, "not equivalent bytes") + if !mock.Failed { + t.Error("Check should fail") + } + }) +} + +func TestRequireYAMLEqT(t *testing.T) { + t.Parallel() + + t.Run("should pass", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + target.YAMLEqT(mock, []byte(expectedYAML), actualYAML) + if mock.Failed { + t.Error("Check should pass") + } + }) + + t.Run("should fail", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + target.YAMLEqT(mock, []byte(`{"foo": "bar"}`), `{"foo": "bar", "hello": "world"}`) + if !mock.Failed { + t.Error("Check should fail") + } + }) +} + func TestRequireYAMLUnmarshalAsWrapper(t *testing.T) { t.Parallel() From fd3b385b2e6f4b1a4cf7f2b5e25b6255391a99f8 Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Wed, 11 Feb 2026 00:25:35 +0100 Subject: [PATCH 4/5] test(yaml): more tests for full coverage Signed-off-by: Frederic BIDON --- enable/yaml/forward_requirements_test.go | 28 ++++++++ enable/yaml/requirements_test.go | 91 ++++++++++++++++++++++++ 2 files changed, 119 insertions(+) diff --git a/enable/yaml/forward_requirements_test.go b/enable/yaml/forward_requirements_test.go index ecccc74df..4724945ff 100644 --- a/enable/yaml/forward_requirements_test.go +++ b/enable/yaml/forward_requirements_test.go @@ -155,6 +155,34 @@ func TestRequireYAMLEqWrapper_ArraysOfDifferentOrder(t *testing.T) { } } +func TestRequireYAMLEqBytesWrapper(t *testing.T) { + t.Parallel() + + t.Run("should pass", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + mockRequire := target.New(mock) + + mockRequire.YAMLEqBytes([]byte(expectedYAML), []byte(actualYAML)) + if mock.Failed { + t.Error("Check should pass") + } + }) + + t.Run("should fail", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + mockRequire := target.New(mock) + + mockRequire.YAMLEqBytes([]byte(`{"foo": "bar"}`), []byte(`{"foo": "bar", "hello": "world"}`)) + if !mock.Failed { + t.Error("Check should fail") + } + }) +} + func TestRequireYAMLEqfWrapper(t *testing.T) { t.Parallel() diff --git a/enable/yaml/requirements_test.go b/enable/yaml/requirements_test.go index b9419d359..5e3f7de6e 100644 --- a/enable/yaml/requirements_test.go +++ b/enable/yaml/requirements_test.go @@ -211,6 +211,97 @@ func TestRequireYAMLEqT(t *testing.T) { }) } +func TestRequireYAMLEqBytes(t *testing.T) { + t.Parallel() + + t.Run("should pass", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + target.YAMLEqBytes(mock, []byte(expectedYAML), []byte(actualYAML)) + if mock.Failed { + t.Error("Check should pass") + } + }) + + t.Run("should fail", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + target.YAMLEqBytes(mock, []byte(`{"foo": "bar"}`), []byte(`{"foo": "bar", "hello": "world"}`)) + if !mock.Failed { + t.Error("Check should fail") + } + }) +} + +func TestRequireYAMLEqTf(t *testing.T) { + t.Parallel() + + t.Run("should pass", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + target.YAMLEqTf(mock, []byte(expectedYAML), actualYAML, yamlCheckMsg, "equivalent") + if mock.Failed { + t.Error("Check should pass") + } + }) + + t.Run("should fail", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + target.YAMLEqTf(mock, []byte(`{"foo": "bar"}`), `{"foo": "bar", "hello": "world"}`, yamlCheckMsg, "not equivalent") + if !mock.Failed { + t.Error("Check should fail") + } + }) +} + +func TestRequireYAMLMarshalUnmarshalAsTf(t *testing.T) { + t.Parallel() + + type dummy struct { + Hello string `yaml:"hello"` + Foo string `yaml:"foo"` + } + + t.Run("should pass", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + + value := dummy{Hello: "world", Foo: "bar"} + target.YAMLUnmarshalAsTf(mock, value, `{"hello": "world", "foo": "bar"}`, yamlCheckMsg, "unmarshal") + if mock.Failed { + t.Error("Check should pass") + } + + target.YAMLMarshalAsTf(mock, `{"hello": "world", "foo": "bar"}`, value, yamlCheckMsg, "marshal") + if mock.Failed { + t.Error("Check should pass") + } + }) + + t.Run("should fail", func(t *testing.T) { + t.Parallel() + + mock := new(mockT) + + value := dummy{Hello: "world", Foo: "bar"} + target.YAMLUnmarshalAsTf(mock, value, `{"hello": "world", "foo": "yay"}`, yamlCheckMsg, "unmarshal") + if !mock.Failed { + t.Error("Check should fail with FailNow") + } + + target.YAMLMarshalAsTf(mock, `{"hello": "world", "foo": "yay"}`, value, yamlCheckMsg, "marshal") + if !mock.Failed { + t.Error("Check should fail with FailNow") + } + }) +} + func TestRequireYAMLUnmarshalAsWrapper(t *testing.T) { t.Parallel() From 5994d1feba7bdfb50690a0e45cb17a4f057d3386 Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Wed, 11 Feb 2026 00:34:53 +0100 Subject: [PATCH 5/5] test(yaml): last missing piece for yaml Signed-off-by: Frederic BIDON --- enable/yaml/forward_assertions_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/enable/yaml/forward_assertions_test.go b/enable/yaml/forward_assertions_test.go index 5dd31c1f9..0c8deef58 100644 --- a/enable/yaml/forward_assertions_test.go +++ b/enable/yaml/forward_assertions_test.go @@ -124,6 +124,28 @@ func TestYAMLEqWrapper_ArraysOfDifferentOrder(t *testing.T) { } } +func TestYAMLEqBytesWrapper(t *testing.T) { + t.Parallel() + + t.Run("should pass", func(t *testing.T) { + t.Parallel() + + assert := target.New(new(testing.T)) + if !assert.YAMLEqBytes([]byte(expectedYAML), []byte(actualYAML)) { + t.Error("YAMLEqBytes should return true") + } + }) + + t.Run("should fail", func(t *testing.T) { + t.Parallel() + + assert := target.New(new(testing.T)) + if assert.YAMLEqBytes([]byte(`{"foo": "bar"}`), []byte(`{"foo": "bar", "hello": "world"}`)) { + t.Error("YAMLEqBytes should return false") + } + }) +} + func TestYAMLEqfWrapper(t *testing.T) { t.Parallel()