-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathshortcut_test.go
51 lines (44 loc) · 1 KB
/
shortcut_test.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
51
package shortcut
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestExtractShortcutStoryID(t *testing.T) {
testCases := []struct {
title string
expectedID string
expectedErr bool
}{
{
title: "This is a sample title with a valid story ID sc-12345",
expectedID: "12345",
expectedErr: false,
},
{
title: "No story ID in this title",
expectedID: "",
expectedErr: true,
},
{
title: "Invalid story ID format sc-abcde",
expectedID: "",
expectedErr: true,
},
}
for _, tc := range testCases {
id, err := ExtractShortcutStoryID(tc.title)
if tc.expectedErr {
assert.Error(t, err)
} else {
assert.NoError(t, err)
assert.Equal(t, tc.expectedID, id)
}
}
}
func TestGenerateShortcutStoryURL(t *testing.T) {
baseURL := "https://app.shortcut.com/foo"
ticketID := "12345"
expectedURL := "https://app.shortcut.com/foo/story/12345"
url := GenerateShortcutStoryURL(baseURL, ticketID)
assert.Equal(t, expectedURL, url)
}