@@ -32,63 +32,38 @@ var _ = Describe("Snapshot enable", func() {
3232 })
3333
3434 Describe ("Snapshot enable" , func () {
35- Context ("Snapshot enable without volume id " , func () {
36- It ("return error " , func () {
35+ Context ("Incorrect Usage Tests " , func () {
36+ It ("No arguments " , func () {
3737 err := testhelpers .RunCobraCommand (cliCommand .Command )
3838 Expect (err ).To (HaveOccurred ())
3939 Expect (err .Error ()).To (ContainSubstring ("Incorrect Usage: This command requires one argument" ))
4040 })
41- })
42- Context ("Snapshot enable with wrong volume id" , func () {
43- It ("return error" , func () {
44- err := testhelpers .RunCobraCommand (cliCommand .Command , "abc" )
41+ It ("Bad Volume ID" , func () {
42+ err := testhelpers .RunCobraCommand (cliCommand .Command , "a1234" , "-c=100" , "-s=INTERVAL" )
4543 Expect (err ).To (HaveOccurred ())
4644 Expect (err .Error ()).To (ContainSubstring ("Invalid input for 'Volume ID'. It must be a positive integer." ))
4745 })
48- })
49-
50- Context ("Snapshot enable without -s" , func () {
51- It ("return error" , func () {
52- err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" )
46+ It ("Bad Interval" , func () {
47+ err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" , "--schedule-type=FAKE" , "-c=100" )
5348 Expect (err ).To (HaveOccurred ())
54- Expect (err .Error ()).To (ContainSubstring ("Incorrect Usage: [-s|--schedule-type] is required, options are: HOURLY, DAILY, WEEKLY." ))
49+ Expect (err .Error ()).To (ContainSubstring ("needs to be one of INTERVAL, HOURLY, DAILY, WEEKLY, not FAKE ." ))
5550 })
56- })
57-
58- Context ("Snapshot enable with wrong -s" , func () {
59- It ("return error" , func () {
60- err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" , "-s" , "MONTHLY" )
61- Expect (err ).To (HaveOccurred ())
62- Expect (err .Error ()).To (ContainSubstring ("Incorrect Usage: [-s|--schedule-type] must be HOURLY, DAILY, or WEEKLY." ))
63- })
64- })
65-
66- Context ("Snapshot enable without -c" , func () {
67- It ("return error" , func () {
51+ It ("No Retention Count" , func () {
6852 err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" , "-s" , "HOURLY" )
6953 Expect (err ).To (HaveOccurred ())
70- Expect (err .Error ()).To (ContainSubstring ("Incorrect Usage: '-c|-- retention-count' is required" ))
54+ Expect (err .Error ()).To (ContainSubstring (`required flag(s) " retention-count" not set` ))
7155 })
72- })
73-
74- Context ("Snapshot enable with wrong -m" , func () {
75- It ("return error" , func () {
56+ It ("Bad Minutes Value" , func () {
7657 err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" , "-s" , "HOURLY" , "-c" , "3" , "-m" , "100" )
7758 Expect (err ).To (HaveOccurred ())
7859 Expect (err .Error ()).To (ContainSubstring ("Incorrect Usage: [-m|--minute] value must be between 0 and 59." ))
7960 })
80- })
81-
82- Context ("Snapshot enable with wrong --hour" , func () {
83- It ("return error" , func () {
61+ It ("Wrong Hour" , func () {
8462 err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" , "-s" , "HOURLY" , "-c" , "3" , "-m" , "20" , "--hour" , "50" )
8563 Expect (err ).To (HaveOccurred ())
8664 Expect (err .Error ()).To (ContainSubstring ("Incorrect Usage: [-r|--hour] value must be between 0 and 23." ))
8765 })
88- })
89-
90- Context ("Snapshot enable with wrong -d" , func () {
91- It ("return error" , func () {
66+ It ("Wrong Days of the Week" , func () {
9267 err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" , "-s" , "HOURLY" , "-c" , "3" , "-m" , "20" , "--hour" , "10" , "-d" , "10" )
9368 Expect (err ).To (HaveOccurred ())
9469 Expect (err .Error ()).To (ContainSubstring ("Incorrect Usage: [-d|--day-of-week] value must be between 0 and 6." ))
@@ -99,22 +74,26 @@ var _ = Describe("Snapshot enable", func() {
9974 BeforeEach (func () {
10075 FakeStorageManager .EnableSnapshotReturns (nil )
10176 })
102- It ("return no error " , func () {
77+ It ("Happy Path All Options " , func () {
10378 err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" , "-s" , "HOURLY" , "-c" , "3" , "-m" , "20" , "--hour" , "10" , "-d" , "0" )
10479 Expect (err ).NotTo (HaveOccurred ())
10580 Expect (fakeUI .Outputs ()).To (ContainSubstring ("HOURLY snapshots have been enabled for volume 1234." ))
10681 })
82+ It ("Happy Path min Options" , func () {
83+ err := testhelpers .RunCobraCommand (cliCommand .Command , "9999" , "-s" , "INTERVAL" , "-c" , "500" )
84+ Expect (err ).NotTo (HaveOccurred ())
85+ Expect (fakeUI .Outputs ()).To (ContainSubstring ("INTERVAL snapshots have been enabled for volume 9999." ))
86+ })
10787 })
10888
10989 Context ("Snapshot enable with correct parameters but server API call fails" , func () {
11090 BeforeEach (func () {
11191 FakeStorageManager .EnableSnapshotReturns (errors .New ("Internal Server Error" ))
11292 })
113- It ("return error" , func () {
93+ It ("API error" , func () {
11494 err := testhelpers .RunCobraCommand (cliCommand .Command , "1234" , "-s" , "HOURLY" , "-c" , "3" , "-m" , "20" , "--hour" , "10" , "-d" , "0" )
11595 Expect (err ).To (HaveOccurred ())
11696 Expect (err .Error ()).To (ContainSubstring ("Failed to enable HOURLY snapshot for volume 1234." ))
117-
11897 })
11998 })
12099 })
0 commit comments