Files
influx-cli/clients/replication/replication_test.go
William Baker f32a55f3bf feat: add drop-non-retryable-data to replications commands (#330)
* feat: add drop-non-retryable-data to replications commands

* refactor: use drop vs nodrop flags

* chore: use the built-in PtrBool
2021-11-17 14:16:58 -07:00

50 lines
1.2 KiB
Go

package replication
import (
"errors"
"testing"
"github.com/influxdata/influx-cli/v2/api"
"github.com/stretchr/testify/require"
)
func TestDropNonRetryableDataBoolPtrFromFlags(t *testing.T) {
tests := []struct {
name string
dropNonRetryableData bool
noDropNonRetryableData bool
want *bool
wantErr error
}{
{
name: "both true is an error",
dropNonRetryableData: true,
noDropNonRetryableData: true,
want: nil,
wantErr: errors.New("cannot specify both --drop-non-retryable-data and --no-drop-non-retryable-data at the same time"),
},
{
name: "drop is true",
dropNonRetryableData: true,
want: api.PtrBool(true),
},
{
name: "noDrop is true",
noDropNonRetryableData: true,
want: api.PtrBool(false),
},
{
name: "both nil is nil",
want: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := dropNonRetryableDataBoolPtrFromFlags(tt.dropNonRetryableData, tt.noDropNonRetryableData)
require.Equal(t, tt.want, got)
require.Equal(t, tt.wantErr, err)
})
}
}