5
5
"io/ioutil"
6
6
"os"
7
7
"path/filepath"
8
+ "strconv"
8
9
"strings"
10
+ "time"
9
11
10
12
. "github.com/onsi/ginkgo"
11
13
. "github.com/onsi/gomega"
@@ -18,11 +20,13 @@ var _ = Describe("Project", func() {
18
20
var result * scaffoldtest.TestResult
19
21
var writeToPath , goldenPath string
20
22
var s * scaffold.Scaffold
23
+ var year string
21
24
22
25
JustBeforeEach (func () {
23
26
s , result = scaffoldtest .NewTestScaffold (writeToPath , goldenPath )
24
27
s .BoilerplateOptional = true
25
28
s .ProjectOptional = true
29
+ year = strconv .Itoa (time .Now ().Year ())
26
30
})
27
31
28
32
Describe ("scaffolding a boilerplate file" , func () {
@@ -32,7 +36,7 @@ var _ = Describe("Project", func() {
32
36
})
33
37
34
38
It ("should match the golden file" , func () {
35
- instance := & Boilerplate {Year : "2019" , License : "apache2" , Owner : "The Kubernetes authors" }
39
+ instance := & Boilerplate {Year : year , License : "apache2" , Owner : "The Kubernetes authors" }
36
40
Expect (s .Execute (input.Options {}, instance )).NotTo (HaveOccurred ())
37
41
Expect (result .Actual .String ()).To (BeEquivalentTo (result .Golden ))
38
42
})
@@ -45,15 +49,15 @@ var _ = Describe("Project", func() {
45
49
46
50
Context ("for apache2" , func () {
47
51
It ("should write the apache2 boilerplate with specified owners" , func () {
48
- instance := & Boilerplate {Year : "2019" , Owner : "Example Owners" }
52
+ instance := & Boilerplate {Year : year , Owner : "Example Owners" }
49
53
Expect (s .Execute (input.Options {}, instance )).NotTo (HaveOccurred ())
50
54
e := strings .Replace (
51
55
result .Golden , "The Kubernetes authors" , "Example Owners" , - 1 )
52
56
Expect (result .Actual .String ()).To (BeEquivalentTo (e ))
53
57
})
54
58
55
59
It ("should use apache2 as the default" , func () {
56
- instance := & Boilerplate {Year : "2019" , Owner : "The Kubernetes authors" }
60
+ instance := & Boilerplate {Year : year , Owner : "The Kubernetes authors" }
57
61
Expect (s .Execute (input.Options {}, instance )).NotTo (HaveOccurred ())
58
62
Expect (result .Actual .String ()).To (BeEquivalentTo (result .Golden ))
59
63
})
@@ -62,11 +66,11 @@ var _ = Describe("Project", func() {
62
66
Context ("for none" , func () {
63
67
It ("should write the empty boilerplate" , func () {
64
68
// Scaffold a boilerplate file
65
- instance := & Boilerplate {Year : "2019" , License : "none" , Owner : "Example Owners" }
69
+ instance := & Boilerplate {Year : year , License : "none" , Owner : "Example Owners" }
66
70
Expect (s .Execute (input.Options {}, instance )).NotTo (HaveOccurred ())
67
- Expect (result .Actual .String ()).To (BeEquivalentTo (`/*
68
- Copyright 2019 Example Owners.
69
- */` ))
71
+ Expect (result .Actual .String ()).To (BeEquivalentTo (fmt . Sprintf ( `/*
72
+ Copyright %s Example Owners.
73
+ */` , year ) ))
70
74
})
71
75
})
72
76
0 commit comments