-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-show-deps.tests.ps1
executable file
·137 lines (116 loc) · 5.78 KB
/
git-show-deps.tests.ps1
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
BeforeAll {
. "$PSScriptRoot/utils/testing.ps1"
Import-Module -Scope Local "$PSScriptRoot/utils/query-state.mocks.psm1"
# User-interface commands are a bit noisy; TODO: add quiet option and test it by making this throw
# Mock -CommandName Write-Host {}
}
Describe 'git-show-deps' {
Describe 'with a remote' {
# Scenario:
# - remote configured
# - dependencies include:
# feature/FOO-123 = main & infra/add-services
# main = none
# infra/add-services = infra/build-infrastructure
# infra/build-infrastructure = none
# - no current branch
BeforeEach {
Initialize-ToolConfiguration
Initialize-DependencyBranches @{
'feature/FOO-123' = $("main", "infra/add-services")
'main' = $()
'infra/add-services' = $('infra/build-infrastructure')
'infra/build-infrastructure' = $()
}
}
It 'shows the results of an dependency branch' {
$result = & ./git-show-deps.ps1 -noFetch -includeRemote -target 'feature/FOO-123'
$result | Should -Be @('origin/main', 'origin/infra/add-services')
}
Describe 'when using the current branch' {
# Scenario, as above, with:
# - current branch is feature/FOO-123
BeforeEach {
Initialize-CurrentBranch 'feature/FOO-123'
}
It 'shows the results of the current branch if none is specified and including remote in the response' {
$result = & ./git-show-deps.ps1 -noFetch -includeRemote
$result | Should -Be @('origin/main', 'origin/infra/add-services')
}
It 'allows specifying the branch with arguments and including remote in the response' {
$result = & ./git-show-deps.ps1 -noFetch -includeRemote -target infra/add-services
$result | Should -Be @('origin/infra/build-infrastructure')
}
It 'shows recursive the results of the current branch if none is specified and including remote in the response' {
$result = & ./git-show-deps.ps1 -noFetch -includeRemote -recurse
$result | Should -Be @('origin/main', 'origin/infra/add-services', 'origin/infra/build-infrastructure')
}
It 'shows the results of the current branch if none is specified' {
$result = & ./git-show-deps.ps1 -noFetch
$result | Should -Be @('main', 'infra/add-services')
}
It 'allows specifying the branch with arguments' {
$result = & ./git-show-deps.ps1 -noFetch -target infra/add-services
$result | Should -Be @('infra/build-infrastructure')
}
It 'shows recursive the results of the current branch if none is specified' {
$result = & ./git-show-deps.ps1 -noFetch -recurse
$result | Should -Be @('main', 'infra/add-services', 'infra/build-infrastructure')
}
}
}
Describe 'without a remote' {
# Scenario:
# - remote configured
# - dependencies include:
# feature/FOO-123 = main & infra/add-services
# main = none
# infra/add-services = infra/build-infrastructure
# infra/build-infrastructure = none
# - no current branch
BeforeEach {
Initialize-ToolConfiguration -noRemote
Initialize-DependencyBranches @{
'feature/FOO-123' = $("main", "infra/add-services")
'main' = $()
'infra/add-services' = $('infra/build-infrastructure')
'infra/build-infrastructure' = $()
}
}
It 'shows the results of an dependency branch' {
$result = & ./git-show-deps.ps1 -noFetch -includeRemote -target 'feature/FOO-123'
$result | Should -Be @('main', 'infra/add-services')
}
Describe 'when using the current branch' {
# Scenario, as above, with:
# - current branch is feature/FOO-123
BeforeEach {
Initialize-CurrentBranch 'feature/FOO-123'
}
It 'shows the results of the current branch if none is specified and including remote in the response' {
$result = & ./git-show-deps.ps1 -noFetch -includeRemote
$result | Should -Be @('main', 'infra/add-services')
}
It 'allows specifying the branch with arguments and including remote in the response' {
$result = & ./git-show-deps.ps1 -noFetch -includeRemote -target infra/add-services
$result | Should -Be @('infra/build-infrastructure')
}
It 'shows recursive the results of the current branch if none is specified and including remote in the response' {
$result = & ./git-show-deps.ps1 -noFetch -includeRemote -recurse
$result | Should -Be @('main', 'infra/add-services', 'infra/build-infrastructure')
}
It 'shows the results of the current branch if none is specified' {
$result = & ./git-show-deps.ps1 -noFetch
$result | Should -Be @('main', 'infra/add-services')
}
It 'allows specifying the branch with arguments' {
$result = & ./git-show-deps.ps1 -noFetch -target infra/add-services
$result | Should -Be @('infra/build-infrastructure')
}
It 'shows recursive the results of the current branch if none is specified' {
$result = & ./git-show-deps.ps1 -noFetch -recurse
$result | Should -Be @('main', 'infra/add-services', 'infra/build-infrastructure')
}
}
}
}