-
Notifications
You must be signed in to change notification settings - Fork 1
/
testcase_unarchive.go
50 lines (40 loc) · 1.1 KB
/
testcase_unarchive.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package cmd
import (
"log"
"github.com/spf13/cobra"
)
var (
// testCaseUnArchiveCmd represents the test case unarchive command
testCaseUnArchiveCmd = &cobra.Command{
Use: "unarchive <test-case-ref>",
Aliases: []string{"unar", "ua"},
Short: "Unarchive a test case.",
Long: `Mark the specified test case as not archived"
<test-case-ref> can be 'organisation-name/test-case-name' or 'test-case-uid'.
`,
Run: runTestCaseUnArchive,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if len(args) < 1 {
log.Fatal("Missing argument: test case reference")
}
if len(args) > 2 {
log.Fatal("Too many arguments")
}
},
ValidArgsFunction: completeOrgaAndCase,
}
)
func init() {
TestCaseCmd.AddCommand(testCaseUnArchiveCmd)
}
func runTestCaseUnArchive(cmd *cobra.Command, args []string) {
client := NewClient()
testCaseUID := mustLookupTestCase(client, args[0])
success, response, err := client.TestCaseUnArchive(testCaseUID)
if err != nil {
log.Fatal(err)
}
if !success {
log.Fatalf("Test case definition could not be unarchived!\n%s\n", string(response))
}
}