consul/command/resource/client/helper_test.go
wangxinyi7 b1bd6ab91a
revert grpc to http (#20716)
* Revert "refactor the resource client (#20343)"

This reverts commit 3c5cb04b0f4e399e57d9cde72d4a4270a9798fe3.

* Revert "clean up http client (#20342)"

This reverts commit 2b89025eabd6240b0cd4f3e6f0f327531567e339.

* remove deprecated peer

* fix the typo

* remove forwarding test as it tests grpc, should add it back
2024-02-23 12:27:49 -08:00

71 lines
1.2 KiB
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package client
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestTValue(t *testing.T) {
t.Run("String: set", func(t *testing.T) {
var tv TValue[string]
err := tv.Set("testString")
assert.NoError(t, err)
assert.Equal(t, *tv.v, "testString")
})
t.Run("String: merge", func(t *testing.T) {
var tv TValue[string]
var onto string
testStr := "testString"
tv.v = &testStr
tv.Merge(&onto)
assert.Equal(t, onto, "testString")
})
t.Run("String: merge nil", func(t *testing.T) {
var tv TValue[string]
var onto *string = nil
testStr := "testString"
tv.v = &testStr
err := tv.Merge(onto)
assert.Equal(t, err.Error(), "onto is nil")
})
t.Run("Get string", func(t *testing.T) {
var tv TValue[string]
testStr := "testString"
tv.v = &testStr
assert.Equal(t, tv.String(), "testString")
})
t.Run("Bool: set", func(t *testing.T) {
var tv TValue[bool]
err := tv.Set("true")
assert.NoError(t, err)
assert.Equal(t, *tv.v, true)
})
t.Run("Bool: merge", func(t *testing.T) {
var tv TValue[bool]
var onto bool
testBool := true
tv.v = &testBool
tv.Merge(&onto)
assert.Equal(t, onto, true)
})
}