mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 13:55:55 +00:00
structs: add tests for String() methods
To show that printing one of these IDs works properly now that the String() method receiver is no longer a pointer.
This commit is contained in:
parent
d113f0e690
commit
2187808803
41
agent/structs/structs_oss_test.go
Normal file
41
agent/structs/structs_oss_test.go
Normal file
@ -0,0 +1,41 @@
|
||||
package structs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestServiceID_String(t *testing.T) {
|
||||
t.Run("value", func(t *testing.T) {
|
||||
sid := NewServiceID("the-id", &EnterpriseMeta{})
|
||||
require.Equal(t, "the-id", fmt.Sprintf("%v", sid))
|
||||
})
|
||||
t.Run("pointer", func(t *testing.T) {
|
||||
sid := NewServiceID("the-id", &EnterpriseMeta{})
|
||||
require.Equal(t, "the-id", fmt.Sprintf("%v", &sid))
|
||||
})
|
||||
}
|
||||
|
||||
func TestCheckID_String(t *testing.T) {
|
||||
t.Run("value", func(t *testing.T) {
|
||||
cid := NewCheckID("the-id", &EnterpriseMeta{})
|
||||
require.Equal(t, "the-id", fmt.Sprintf("%v", cid))
|
||||
})
|
||||
t.Run("pointer", func(t *testing.T) {
|
||||
cid := NewCheckID("the-id", &EnterpriseMeta{})
|
||||
require.Equal(t, "the-id", fmt.Sprintf("%v", &cid))
|
||||
})
|
||||
}
|
||||
|
||||
func TestServiceName_String(t *testing.T) {
|
||||
t.Run("value", func(t *testing.T) {
|
||||
sn := NewServiceName("the-id", &EnterpriseMeta{})
|
||||
require.Equal(t, "the-id", fmt.Sprintf("%v", sn))
|
||||
})
|
||||
t.Run("pointer", func(t *testing.T) {
|
||||
sn := NewServiceName("the-id", &EnterpriseMeta{})
|
||||
require.Equal(t, "the-id", fmt.Sprintf("%v", &sn))
|
||||
})
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user