Skip to content

Commit d922a37

Browse files
committed
update test
1 parent e78a1bd commit d922a37

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ require (
88
github.com/sirupsen/logrus v1.9.3
99
github.com/spf13/cobra v1.8.0
1010
github.com/spf13/viper v1.18.2
11+
github.com/stretchr/testify v1.8.4
1112
)
1213

1314
require (
1415
github.com/armon/go-metrics v0.4.1 // indirect
16+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
1517
github.com/fatih/color v1.16.0 // indirect
1618
github.com/fsnotify/fsnotify v1.7.0 // indirect
1719
github.com/hashicorp/errwrap v1.1.0 // indirect
@@ -30,6 +32,7 @@ require (
3032
github.com/mitchellh/go-homedir v1.1.0 // indirect
3133
github.com/mitchellh/mapstructure v1.5.0 // indirect
3234
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
35+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
3336
github.com/sagikazarmark/locafero v0.4.0 // indirect
3437
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
3538
github.com/sourcegraph/conc v0.3.0 // indirect

pkg/tagit/tagit_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"time"
99

1010
"github.com/hashicorp/consul/api"
11+
"github.com/stretchr/testify/assert"
1112
)
1213

1314
func TestDiffTags(t *testing.T) {
@@ -496,3 +497,25 @@ func TestUpdateConsulService(t *testing.T) {
496497
})
497498
}
498499
}
500+
501+
func TestNewConsulAPIWrapper(t *testing.T) {
502+
// Mock Consul API client
503+
consulClient, err := api.NewClient(api.DefaultConfig())
504+
if err != nil {
505+
t.Fatalf("Failed to create Consul client: %v", err)
506+
}
507+
508+
// Test NewConsulAPIWrapper
509+
wrapper := NewConsulAPIWrapper(consulClient)
510+
511+
// Assert that wrapper is not nil
512+
assert.NotNil(t, wrapper, "NewConsulAPIWrapper returned nil")
513+
514+
// Assert that wrapper implements ConsulClient interface
515+
_, isConsulClient := interface{}(wrapper).(ConsulClient)
516+
assert.True(t, isConsulClient, "NewConsulAPIWrapper does not implement ConsulClient interface")
517+
518+
// Optionally, assert that wrapper's Agent method returns a ConsulAgent
519+
_, isConsulAgent := wrapper.Agent().(ConsulAgent)
520+
assert.True(t, isConsulAgent, "Wrapper's Agent method does not return a ConsulAgent")
521+
}

0 commit comments

Comments
 (0)