feat: update restore
to support InfluxDB 2.0.x (#185)
This commit is contained in:
@ -337,61 +337,3 @@ func (e *notFoundErr) Error() string {
|
||||
func (e *notFoundErr) ErrorCode() api.ErrorCode {
|
||||
return api.ERRORCODE_NOT_FOUND
|
||||
}
|
||||
|
||||
func TestBackup_ServerIsLegacy(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
versionStr *string
|
||||
legacy bool
|
||||
wantErr string
|
||||
}{
|
||||
{
|
||||
name: "2.0.x",
|
||||
versionStr: api.PtrString("2.0.7"),
|
||||
legacy: true,
|
||||
},
|
||||
{
|
||||
name: "2.1.x",
|
||||
versionStr: api.PtrString("2.1.0-RC1"),
|
||||
},
|
||||
{
|
||||
name: "nightly",
|
||||
versionStr: api.PtrString("nightly-2020-01-01"),
|
||||
},
|
||||
{
|
||||
name: "dev",
|
||||
versionStr: api.PtrString("some.custom-version.2"),
|
||||
},
|
||||
{
|
||||
name: "1.x",
|
||||
versionStr: api.PtrString("1.9.3"),
|
||||
wantErr: "InfluxDB v1 does not support the APIs",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctrl := gomock.NewController(t)
|
||||
healthApi := mock.NewMockHealthApi(ctrl)
|
||||
healthApi.EXPECT().GetHealth(gomock.Any()).Return(api.ApiGetHealthRequest{ApiService: healthApi})
|
||||
healthApi.EXPECT().GetHealthExecute(gomock.Any()).Return(api.HealthCheck{Version: tc.versionStr}, nil)
|
||||
|
||||
client := Client{HealthApi: healthApi}
|
||||
isLegacy, err := client.serverIsLegacy(context.Background())
|
||||
|
||||
if tc.wantErr != "" {
|
||||
require.Error(t, err)
|
||||
require.Contains(t, err.Error(), tc.wantErr)
|
||||
return
|
||||
}
|
||||
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, tc.legacy, isLegacy)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user