google-api-go-generator: fix tests to not be sensitive to change in year
Fix test failure from CL 35750 which changed the copyright header's year
automatically.
Change-Id: I1cad456d11624a424bc52c54675767a4c824f098
Reviewed-on: https://code-review.googlesource.com/c/38430
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/google-api-go-generator/gen_test.go b/google-api-go-generator/gen_test.go
index 2fde686..90acf2b 100644
--- a/google-api-go-generator/gen_test.go
+++ b/google-api-go-generator/gen_test.go
@@ -17,10 +17,12 @@
import (
"bytes"
"flag"
+ "fmt"
"io/ioutil"
"path/filepath"
"strings"
"testing"
+ "time"
)
var updateGolden = flag.Bool("update_golden", false, "If true, causes TestAPIs to update golden files")
@@ -73,6 +75,7 @@
t.Error(err)
continue
}
+ want = bytes.Replace(want, []byte("Copyright YEAR"), []byte(fmt.Sprintf("Copyright %d", time.Now().Year())), -1)
if !bytes.Equal(want, clean) {
tf, _ := ioutil.TempFile("", "api-"+name+"-got-json.")
tf.Write(clean)
diff --git a/google-api-go-generator/testdata/any.want b/google-api-go-generator/testdata/any.want
index 9548702..9bbf4ca 100644
--- a/google-api-go-generator/testdata/any.want
+++ b/google-api-go-generator/testdata/any.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/arrayofarray-1.want b/google-api-go-generator/testdata/arrayofarray-1.want
index 70e5acc..fe3a5c3 100644
--- a/google-api-go-generator/testdata/arrayofarray-1.want
+++ b/google-api-go-generator/testdata/arrayofarray-1.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/arrayofenum.want b/google-api-go-generator/testdata/arrayofenum.want
index 1a7fab4..4c0a53f 100644
--- a/google-api-go-generator/testdata/arrayofenum.want
+++ b/google-api-go-generator/testdata/arrayofenum.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/arrayofmapofobjects.want b/google-api-go-generator/testdata/arrayofmapofobjects.want
index 3952a51..f48c5e0 100644
--- a/google-api-go-generator/testdata/arrayofmapofobjects.want
+++ b/google-api-go-generator/testdata/arrayofmapofobjects.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/arrayofmapofstrings.want b/google-api-go-generator/testdata/arrayofmapofstrings.want
index 606a175..51f61b0 100644
--- a/google-api-go-generator/testdata/arrayofmapofstrings.want
+++ b/google-api-go-generator/testdata/arrayofmapofstrings.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/blogger-3.want b/google-api-go-generator/testdata/blogger-3.want
index da885d7..151d38d 100644
--- a/google-api-go-generator/testdata/blogger-3.want
+++ b/google-api-go-generator/testdata/blogger-3.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/floats.want b/google-api-go-generator/testdata/floats.want
index 9c4f260..b8696ec 100644
--- a/google-api-go-generator/testdata/floats.want
+++ b/google-api-go-generator/testdata/floats.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/getwithoutbody.want b/google-api-go-generator/testdata/getwithoutbody.want
index 53b6e58..8b05e51 100644
--- a/google-api-go-generator/testdata/getwithoutbody.want
+++ b/google-api-go-generator/testdata/getwithoutbody.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/json-body.want b/google-api-go-generator/testdata/json-body.want
index 7828e85..0ebe31f 100644
--- a/google-api-go-generator/testdata/json-body.want
+++ b/google-api-go-generator/testdata/json-body.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/mapofany.want b/google-api-go-generator/testdata/mapofany.want
index 5d57bcd..acf01fd 100644
--- a/google-api-go-generator/testdata/mapofany.want
+++ b/google-api-go-generator/testdata/mapofany.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/mapofarrayofobjects.want b/google-api-go-generator/testdata/mapofarrayofobjects.want
index 631d675..795c7e7 100644
--- a/google-api-go-generator/testdata/mapofarrayofobjects.want
+++ b/google-api-go-generator/testdata/mapofarrayofobjects.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/mapofint64strings.want b/google-api-go-generator/testdata/mapofint64strings.want
index 0df4329..db21159 100644
--- a/google-api-go-generator/testdata/mapofint64strings.want
+++ b/google-api-go-generator/testdata/mapofint64strings.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/mapofobjects.want b/google-api-go-generator/testdata/mapofobjects.want
index 5ce4f29..5623e90 100644
--- a/google-api-go-generator/testdata/mapofobjects.want
+++ b/google-api-go-generator/testdata/mapofobjects.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/mapofstrings-1.want b/google-api-go-generator/testdata/mapofstrings-1.want
index 42167b1..68216e4 100644
--- a/google-api-go-generator/testdata/mapofstrings-1.want
+++ b/google-api-go-generator/testdata/mapofstrings-1.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/param-rename.want b/google-api-go-generator/testdata/param-rename.want
index d40bfb3..76b14fb 100644
--- a/google-api-go-generator/testdata/param-rename.want
+++ b/google-api-go-generator/testdata/param-rename.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/quotednum.want b/google-api-go-generator/testdata/quotednum.want
index 53b35d1..ca0a50e 100644
--- a/google-api-go-generator/testdata/quotednum.want
+++ b/google-api-go-generator/testdata/quotednum.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/repeated.want b/google-api-go-generator/testdata/repeated.want
index 309a718..d609152 100644
--- a/google-api-go-generator/testdata/repeated.want
+++ b/google-api-go-generator/testdata/repeated.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/required-query.want b/google-api-go-generator/testdata/required-query.want
index 9590f50..27b0e7e 100644
--- a/google-api-go-generator/testdata/required-query.want
+++ b/google-api-go-generator/testdata/required-query.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/resource-named-service.want b/google-api-go-generator/testdata/resource-named-service.want
index d2814c7..abf56c6 100644
--- a/google-api-go-generator/testdata/resource-named-service.want
+++ b/google-api-go-generator/testdata/resource-named-service.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/unfortunatedefaults.want b/google-api-go-generator/testdata/unfortunatedefaults.want
index 31baf62..4d1cd9a 100644
--- a/google-api-go-generator/testdata/unfortunatedefaults.want
+++ b/google-api-go-generator/testdata/unfortunatedefaults.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/variants.want b/google-api-go-generator/testdata/variants.want
index 472e82f..6cd08ec 100644
--- a/google-api-go-generator/testdata/variants.want
+++ b/google-api-go-generator/testdata/variants.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/google-api-go-generator/testdata/wrapnewlines.want b/google-api-go-generator/testdata/wrapnewlines.want
index ae1f15a..32ae79e 100644
--- a/google-api-go-generator/testdata/wrapnewlines.want
+++ b/google-api-go-generator/testdata/wrapnewlines.want
@@ -1,4 +1,4 @@
-// Copyright 2019 Google Inc. All rights reserved.
+// Copyright YEAR Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.