55 "io/ioutil"
66 "os"
77 "path/filepath"
8+ "strconv"
89 "strings"
10+ "time"
911
1012 . "github.com/onsi/ginkgo"
1113 . "github.com/onsi/gomega"
@@ -18,11 +20,13 @@ var _ = Describe("Project", func() {
1820 var result * scaffoldtest.TestResult
1921 var writeToPath , goldenPath string
2022 var s * scaffold.Scaffold
23+ var year string
2124
2225 JustBeforeEach (func () {
2326 s , result = scaffoldtest .NewTestScaffold (writeToPath , goldenPath )
2427 s .BoilerplateOptional = true
2528 s .ProjectOptional = true
29+ year = strconv .Itoa (time .Now ().Year ())
2630 })
2731
2832 Describe ("scaffolding a boilerplate file" , func () {
@@ -32,7 +36,7 @@ var _ = Describe("Project", func() {
3236 })
3337
3438 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" }
3640 Expect (s .Execute (input.Options {}, instance )).NotTo (HaveOccurred ())
3741 Expect (result .Actual .String ()).To (BeEquivalentTo (result .Golden ))
3842 })
@@ -45,15 +49,15 @@ var _ = Describe("Project", func() {
4549
4650 Context ("for apache2" , func () {
4751 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" }
4953 Expect (s .Execute (input.Options {}, instance )).NotTo (HaveOccurred ())
5054 e := strings .Replace (
5155 result .Golden , "The Kubernetes authors" , "Example Owners" , - 1 )
5256 Expect (result .Actual .String ()).To (BeEquivalentTo (e ))
5357 })
5458
5559 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" }
5761 Expect (s .Execute (input.Options {}, instance )).NotTo (HaveOccurred ())
5862 Expect (result .Actual .String ()).To (BeEquivalentTo (result .Golden ))
5963 })
@@ -62,11 +66,11 @@ var _ = Describe("Project", func() {
6266 Context ("for none" , func () {
6367 It ("should write the empty boilerplate" , func () {
6468 // Scaffold a boilerplate file
65- instance := & Boilerplate {Year : "2019" , License : "none" , Owner : "Example Owners" }
69+ instance := & Boilerplate {Year : year , License : "none" , Owner : "Example Owners" }
6670 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 ) ))
7074 })
7175 })
7276
0 commit comments