-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Unit Test For Blob Commands Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com> * Add Unit Test For Blob Commands Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com> * Rearrange Imports * Add Constants * Add Unit Tests for maintenance.go * Add Unit Tests for parse_command_output.go * Add Unit Tests for policy_set_global.go * Add Unit Tests for restore.go Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com> * Updates Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com> * Add unit test for server.go Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com> * Added Unit Test for snapshot.go Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com> * Added Unit Test for get_maintenance_owner.go Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com> * Added github.com/frankban/quicktest in go.mod Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com> * Add Unit Test for repository.go Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com> * Update Tests Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com> * Fix Linting Problems Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com> * Fix Failing Unit Test Problems Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com> * Replace Dependencies Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com> * Use testing and gocheck instead of quicktest for UT Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com> * Resolve Conflict --> Update go.mod and go.sum Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com> * Add Newline in go.sum Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com> Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>
- Loading branch information
Showing
12 changed files
with
1,219 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright 2022 The Kanister Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package command | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
. "gopkg.in/check.v1" | ||
) | ||
|
||
// Hook up gocheck into the "go test" runner. | ||
func TestKopiaCommandWrappers(t *testing.T) { TestingT(t) } | ||
|
||
type KopiaBlobTestSuite struct{} | ||
|
||
var _ = Suite(&KopiaBlobTestSuite{}) | ||
|
||
func (kBlob *KopiaBlobTestSuite) TestBlobCommands(c *C) { | ||
commandArgs := &CommandArgs{ | ||
RepoPassword: "encr-key", | ||
ConfigFilePath: "path/kopia.config", | ||
LogDirectory: "cache/log", | ||
} | ||
|
||
for _, tc := range []struct { | ||
f func() []string | ||
expectedLog string | ||
}{ | ||
{ | ||
f: func() []string { | ||
args := BlobListCommandArgs{ | ||
CommandArgs: commandArgs, | ||
} | ||
return BlobList(args) | ||
}, | ||
expectedLog: "kopia --log-level=error --config-file=path/kopia.config --log-dir=cache/log --password=encr-key blob list", | ||
}, | ||
{ | ||
f: func() []string { | ||
args := BlobStatsCommandArgs{ | ||
CommandArgs: commandArgs, | ||
} | ||
return BlobStats(args) | ||
}, | ||
expectedLog: "kopia --log-level=error --config-file=path/kopia.config --log-dir=cache/log --password=encr-key blob stats --raw", | ||
}, | ||
} { | ||
cmd := strings.Join(tc.f(), " ") | ||
c.Assert(cmd, Equals, tc.expectedLog) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright 2022 The Kanister Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package command | ||
|
||
import ( | ||
"strings" | ||
|
||
. "gopkg.in/check.v1" | ||
) | ||
|
||
type KopiaMaintenanceTestSuite struct{} | ||
|
||
var _ = Suite(&KopiaMaintenanceTestSuite{}) | ||
|
||
func (kMaintenance *KopiaMaintenanceTestSuite) TestMaintenanceCommands(c *C) { | ||
commandArgs := &CommandArgs{ | ||
RepoPassword: "encr-key", | ||
ConfigFilePath: "path/kopia.config", | ||
LogDirectory: "cache/log", | ||
} | ||
|
||
for _, tc := range []struct { | ||
f func() []string | ||
expectedLog string | ||
}{ | ||
{ | ||
f: func() []string { | ||
args := MaintenanceInfoCommandArgs{ | ||
CommandArgs: commandArgs, | ||
GetJsonOutput: false, | ||
} | ||
return MaintenanceInfo(args) | ||
}, | ||
expectedLog: "kopia --log-level=error --config-file=path/kopia.config --log-dir=cache/log --password=encr-key maintenance info", | ||
}, | ||
{ | ||
f: func() []string { | ||
args := MaintenanceInfoCommandArgs{ | ||
CommandArgs: commandArgs, | ||
GetJsonOutput: true, | ||
} | ||
return MaintenanceInfo(args) | ||
}, | ||
expectedLog: "kopia --log-level=error --config-file=path/kopia.config --log-dir=cache/log --password=encr-key maintenance info --json", | ||
}, | ||
{ | ||
f: func() []string { | ||
args := MaintenanceSetOwnerCommandArgs{ | ||
CommandArgs: commandArgs, | ||
CustomOwner: "username@hostname", | ||
} | ||
return MaintenanceSetOwner(args) | ||
}, | ||
expectedLog: "kopia --log-level=error --config-file=path/kopia.config --log-dir=cache/log --password=encr-key maintenance set --owner=username@hostname", | ||
}, | ||
{ | ||
f: func() []string { | ||
args := MaintenanceRunCommandArgs{ | ||
CommandArgs: commandArgs, | ||
} | ||
return MaintenanceRunCommand(args) | ||
}, | ||
expectedLog: "kopia --log-level=error --config-file=path/kopia.config --log-dir=cache/log --password=encr-key maintenance run", | ||
}, | ||
} { | ||
cmd := strings.Join(tc.f(), " ") | ||
c.Check(cmd, Equals, tc.expectedLog) | ||
} | ||
} |
Oops, something went wrong.