From 7c882fb4438b220db1c50d6307f239e806909066 Mon Sep 17 00:00:00 2001 From: Lucas Vieira Date: Tue, 12 Sep 2023 17:52:44 -0700 Subject: [PATCH] make layerfile name definition validation tests more reliable --- internal/layerfile/layerfile_test.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/layerfile/layerfile_test.go b/internal/layerfile/layerfile_test.go index 6ead537..0ddc43c 100644 --- a/internal/layerfile/layerfile_test.go +++ b/internal/layerfile/layerfile_test.go @@ -5,7 +5,6 @@ import ( "path" "testing" - "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -100,7 +99,7 @@ func TestToLayers_ValidateNameOfLayerDefinitions(t *testing.T) { }, }, }, - err: errors.Wrap(ErrInvalidDefinitionName, "invalid name for a layer definition"), + err: ErrInvalidDefinitionName, }, { name: "Name has special character", @@ -111,7 +110,7 @@ func TestToLayers_ValidateNameOfLayerDefinitions(t *testing.T) { }, }, }, - err: errors.Wrap(ErrInvalidDefinitionName, "invalid!"), + err: ErrInvalidDefinitionName, }, { name: "Valid name", @@ -128,10 +127,10 @@ func TestToLayers_ValidateNameOfLayerDefinitions(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { _, err := tt.lf.ToLayers() - if err != nil { - assert.EqualError(t, tt.err, err.Error()) + if tt.err == nil { + assert.NoError(t, err) } else { - assert.NoError(t, tt.err) + assert.ErrorIs(t, err, tt.err) } }) }