-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #666 from k1LoW/refactor-runbook-id
Refactor generating runbook ID
- Loading branch information
Showing
6 changed files
with
132 additions
and
148 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
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
This file was deleted.
Oops, something went wrong.
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,89 @@ | ||
package runn | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
func TestTrailRunbookID(t *testing.T) { | ||
s2 := 2 | ||
s3 := 3 | ||
|
||
tests := []struct { | ||
trails Trails | ||
want string | ||
wantFull string | ||
}{ | ||
{ | ||
Trails{ | ||
Trail{ | ||
Type: TrailTypeRunbook, | ||
RunbookID: "o-a", | ||
}, | ||
}, | ||
"o-a", | ||
"o-a", | ||
}, | ||
{ | ||
Trails{ | ||
Trail{ | ||
Type: TrailTypeRunbook, | ||
RunbookID: "o-c", | ||
}, | ||
Trail{ | ||
Type: TrailTypeStep, | ||
StepIndex: &s2, | ||
StepKey: "s-b", | ||
}, | ||
Trail{ | ||
Type: TrailTypeRunbook, | ||
RunbookID: "o-a", | ||
}, | ||
}, | ||
"o-c", | ||
"o-c?step=2", | ||
}, | ||
{ | ||
Trails{ | ||
Trail{ | ||
Type: TrailTypeRunbook, | ||
RunbookID: "o-e", | ||
}, | ||
Trail{ | ||
Type: TrailTypeStep, | ||
StepIndex: &s3, | ||
StepKey: "s-d", | ||
}, | ||
Trail{ | ||
Type: TrailTypeRunbook, | ||
RunbookID: "o-c", | ||
}, | ||
Trail{ | ||
Type: TrailTypeStep, | ||
StepIndex: &s2, | ||
StepKey: "s-b", | ||
}, | ||
Trail{ | ||
Type: TrailTypeRunbook, | ||
RunbookID: "o-a", | ||
}, | ||
}, | ||
"o-e", | ||
"o-e?step=3&step=2", | ||
}, | ||
} | ||
for i, tt := range tests { | ||
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { | ||
got := tt.trails.runbookID() | ||
if got != tt.want { | ||
t.Errorf("got %v\nwant %v", got, tt.want) | ||
} | ||
{ | ||
got := tt.trails.runbookIDFull() | ||
if got != tt.wantFull { | ||
t.Errorf("got %v\nwant %v", got, tt.wantFull) | ||
} | ||
} | ||
}) | ||
} | ||
} |