-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.sh
215 lines (166 loc) · 5.74 KB
/
test.sh
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#!/bin/sh
set -ex
rm $GOPATH/bin/emd
go install
rm -fr $GOPATH/src/github.com/mh-cbon/emd-test
rm -fr ~/fake
# test 1: a project contained in GOPATH, aliased out of it
mkdir -p ~/fake/src/github.com/mh-cbon/test-emd
ln -s ~/fake/src/github.com/mh-cbon/test-emd $GOPATH/src/github.com/mh-cbon/emd-test
cd ~/fake/src/github.com/mh-cbon/test-emd
export VERBOSE=y
cat <<EOT | emd gen | grep "Name=test-emd" || exit 1;
Name={{.Name}}
EOT
export VERBOSE=""
cat <<EOT | emd gen | grep "ProviderName=github" || exit 1;
ProviderName={{.ProviderName}}
EOT
cat <<EOT | emd gen | grep "URL=github.com/mh-cbon/test-emd" || exit 1;
URL={{.URL}}
EOT
cat <<EOT | emd gen | grep "ProjectURL=github.com/mh-cbon/test-emd" || exit 1;
ProjectURL={{.ProjectURL}}
EOT
cat <<EOT | emd gen | grep "Branch=master" || exit 1;
Branch={{.Branch}}
EOT
cat <<EOT | emd gen | grep "User=mh-cbon" || exit 1;
User={{.User}}
EOT
cat <<EOT | emd gen | grep "ProviderURL=github.com" || exit 1;
ProviderURL={{.ProviderURL}}
EOT
cd ~
rm -fr $GOPATH/src/github.com/mh-cbon/emd-test
rm -fr ~/fake
# test 2: a project not contained in GOPATH, aliased in gopath
mkdir -p ~/fake/src/github.com/mh-cbon/
mkdir -p $GOPATH/src/github.com/mh-cbon/emd-test
ln -s $GOPATH/src/github.com/mh-cbon/emd-test ~/fake/src/github.com/mh-cbon/test-emd
cd ~/fake/src/github.com/mh-cbon/test-emd
export VERBOSE=y
cat <<EOT | emd gen | grep "Name=test-emd" || exit 1;
Name={{.Name}}
EOT
export VERBOSE=""
cat <<EOT | emd gen | grep "ProviderName=github" || exit 1;
ProviderName={{.ProviderName}}
EOT
cat <<EOT | emd gen | grep "URL=github.com/mh-cbon/test-emd" || exit 1;
URL={{.URL}}
EOT
cat <<EOT | emd gen | grep "ProjectURL=github.com/mh-cbon/test-emd" || exit 1;
ProjectURL={{.ProjectURL}}
EOT
cat <<EOT | emd gen | grep "Branch=master" || exit 1;
Branch={{.Branch}}
EOT
cat <<EOT | emd gen | grep "User=mh-cbon" || exit 1;
User={{.User}}
EOT
cat <<EOT | emd gen | grep "ProviderURL=github.com" || exit 1;
ProviderURL={{.ProviderURL}}
EOT
cat <<EOT | emd gen | grep "https://travis-ci.org/mh-cbon/test-emd.svg?branch=master" || exit 1;
{{template "badge/travis" .}}
EOT
cat <<EOT | emd gen | grep "https://travis-ci.org/mh-cbon/test-emd" || exit 1;
{{template "badge/travis" .}}
EOT
cat <<EOT | emd gen | grep "https://ci.appveyor.com/api/projects/status/github/mh-cbon/test-emd?branch=master&svg=true" || exit 1;
{{template "badge/appveyor" .}}
EOT
cat <<EOT | emd gen | grep "https://ci.appveyor.com/project/mh-cbon/test-emd" || exit 1;
{{template "badge/appveyor" .}}
EOT
cat <<EOT | emd gen | grep "https://goreportcard.com/badge/github.com/mh-cbon/test-emd" || exit 1;
{{template "badge/goreport" .}}
EOT
cat <<EOT | emd gen | grep "https://godoc.org/github.com/mh-cbon/test-emd?status.svg" || exit 1;
{{template "badge/godoc" .}}
EOT
cat <<EOT | emd gen | grep "http://godoc.org/github.com/mh-cbon/test-emd" || exit 1;
{{template "badge/godoc" .}}
EOT
cat <<EOT | emd gen | grep "MIT License" || exit 1;
{{render "license/shields" . "License" "MIT" "LicenseFile" "LICENSE" "LicenseColor" "yellow"}}
EOT
cat <<EOT | emd gen | grep "http://img.shields.io/badge/License-MIT-yellow.svg" || exit 1;
{{render "license/shields" . "License" "MIT" "LicenseFile" "LICENSE" "LicenseColor" "yellow"}}
EOT
cat <<EOT | emd gen | grep "(LICENSE)" || exit 1;
{{render "license/shields" . "License" "MIT" "LicenseFile" "LICENSE" "LicenseColor" "yellow"}}
EOT
cat <<EOT | emd gen | grep "[title]" || exit 1;
{{render "badge/codeship" . "CsUUID" "uuid" "CsProjectID" "projectID" "CsTitle" "title"}}
EOT
cat <<EOT | emd gen | grep "https://codeship.com/projects/uuid/status?branch=master" || exit 1;
{{render "badge/codeship" . "CsUUID" "uuid" "CsProjectID" "projectID" "CsTitle" "title"}}
EOT
cat <<EOT | emd gen | grep "https://codeship.com/projects/projectID" || exit 1;
{{render "badge/codeship" . "CsUUID" "uuid" "CsProjectID" "projectID" "CsTitle" "title"}}
EOT
cat <<EOT | emd gen | grep "GOPATH/src/github.com/mh-cbon/test-emd" || exit 1;
{{template "glide/install" . }}
EOT
cat <<EOT | emd gen | grep "git clone https://github.com/mh-cbon/test-emd.git ." || exit 1;
{{template "glide/install" . }}
EOT
cat <<EOT | emd gen | grep "glide install" || exit 1;
{{template "glide/install" . }}
EOT
cat <<EOT | emd gen | grep "choco install test-emd" || exit 1;
{{template "choco/install" . }}
EOT
cat <<EOT | emd gen | grep "https://github.com/mh-cbon/test-emd/releases" || exit 1;
{{template "gh/releases" . }}
EOT
cat <<EOT | emd gen | grep "go get github.com/mh-cbon/test-emd" || exit 1;
{{template "go/install" . }}
EOT
cat <<EOT | emd gen | grep "https://godoc.org/github.com/mh-cbon/test-emd?status.svg" || exit1
{{template "badge/godoc" . }}
EOT
cat <<EOT | emd gen | grep "http://godoc.org/github.com/mh-cbon/test-emd" || exit1
{{template "badge/godoc" . }}
EOT
cat <<EOT | emd gen | grep "https://goreportcard.com/badge/github.com/mh-cbon/test-emd" || exit 1;
{{template "badge/goreport" . }}
EOT
cd ~
rm -fr $GOPATH/src/github.com/mh-cbon/emd-test
rm -fr ~/fake
# test3: ensure emd gen defaults to README.e.md if any.
mkdir -p $GOPATH/src/github.com/mh-cbon/emd-test
cd $GOPATH/src/github.com/mh-cbon/emd-test
cat <<EOT >> README.e.md
templated
EOT
emd gen | grep "templated" || exit 1;
cd ~
rm -fr $GOPATH/src/github.com/mh-cbon/emd-test
rm -fr ~/fake
# test4: ensure emd gen defaults to defTemplate if not any README.e.md .
mkdir -p $GOPATH/src/github.com/mh-cbon/emd-test
cd $GOPATH/src/github.com/mh-cbon/emd-test
emd gen | grep "# emd-test" || exit 1;
# test prelude data.
cat <<EOT | emd gen | grep "value" || exit 1;
---
key: value
---
{{.key}}
EOT
# test prelude data override by cli.
cat <<EOT | emd gen --data '{"key":"nopnop"}' | grep "nopnop" || exit 1;
---
key: value
---
{{.key}}
EOT
cd ~
rm -fr $GOPATH/src/github.com/mh-cbon/emd-test
rm -fr ~/fake
echo ""
echo "ALL GOOD!"