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
This commit is contained in:
49
clients/replication/replication_test.go
Normal file
49
clients/replication/replication_test.go
Normal file
@ -0,0 +1,49 @@
|
||||
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)
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user