Skip to content

Commit 3ece4e7

Browse files
author
Milla Samuel
committed
Add tests
1 parent 9f4f26a commit 3ece4e7

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

fdbclient/admin_client_test.go

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ protocol fdb00b071010000`,
10251025

10261026
url := "blobstore://test@test-service/test-backup"
10271027

1028-
err := client.StartRestore(url, keyRanges, encryptionKeyPath, "mock-versionstamp")
1028+
err := client.StartRestore(url, keyRanges, encryptionKeyPath, "")
10291029
Expect(err).NotTo(HaveOccurred())
10301030

10311031
Expect(mockRunner.receivedArgs[0]).To(ContainElements(
@@ -1051,4 +1051,40 @@ protocol fdb00b071010000`,
10511051
Entry("version that supports backup encryption without key", "7.3.1", "", nil, false, false),
10521052
Entry("version that supports backup encryption with key", "7.3.1", "/path/to/key", nil, true, false),
10531053
)
1054+
1055+
DescribeTable("it should properly handle backup versions",
1056+
func(backupVersion string, shouldHaveBackupVersion bool) {
1057+
mockRunner := &mockCommandRunner{
1058+
mockedError: nil,
1059+
mockedOutput: []string{""},
1060+
}
1061+
1062+
client := &cliAdminClient{
1063+
Cluster: &fdbv1beta2.FoundationDBCluster{
1064+
Spec: fdbv1beta2.FoundationDBClusterSpec{
1065+
Version: "7.3.1",
1066+
},
1067+
Status: fdbv1beta2.FoundationDBClusterStatus{
1068+
RunningVersion: "7.3.1",
1069+
},
1070+
},
1071+
log: logr.Discard(),
1072+
cmdRunner: mockRunner,
1073+
}
1074+
1075+
url := "blobstore://test@test-service/test-backup"
1076+
1077+
err := client.StartRestore(url, nil, "", backupVersion)
1078+
Expect(err).NotTo(HaveOccurred())
1079+
1080+
if shouldHaveBackupVersion {
1081+
Expect(mockRunner.receivedArgs[0]).To(ContainElements("-v", backupVersion))
1082+
} else {
1083+
Expect(mockRunner.receivedArgs[0]).ToNot(ContainElement("-v"))
1084+
}
1085+
1086+
},
1087+
Entry("when it is not passed in", "123456789", true),
1088+
Entry("when it is passed in", "", false),
1089+
)
10541090
})

0 commit comments

Comments
 (0)