File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,11 @@ import (
4
4
"encoding/json"
5
5
"io/ioutil"
6
6
"reflect"
7
+ "regexp"
8
+ "strconv"
9
+ "strings"
7
10
"testing"
11
+ "time"
8
12
)
9
13
10
14
func exampleJson () map [string ]interface {} {
@@ -372,3 +376,29 @@ func TestMarshalUnmarshall(t *testing.T) {
372
376
t .Errorf ("Expected %v, but got %v" , header , newHeader )
373
377
}
374
378
}
379
+
380
+ func TestLicenceDate (t * testing.T ) {
381
+ b , err := ioutil .ReadFile ("./LICENSE.txt" )
382
+
383
+ if err != nil {
384
+ t .Fatalf ("cannot open license file; got %v" , err )
385
+ }
386
+
387
+ r := regexp .MustCompile ("(\\ d+-\\ d+)" )
388
+ dates := r .FindString (string (b ))
389
+
390
+ if dates == "" {
391
+ t .Fatal ("cannot find licence date range in the license file" )
392
+ }
393
+
394
+ lastDate := strings .Split (dates , "-" )[1 ]
395
+ maxLicenseYear , err := strconv .Atoi (lastDate )
396
+
397
+ if err != nil {
398
+ t .Fatalf ("cannot convert licence date to int; got %v" , err )
399
+ }
400
+
401
+ if maxLicenseYear != time .Now ().Year () {
402
+ t .Fatalf ("end licence year must be %d; got %d" , time .Now ().Year (), maxLicenseYear )
403
+ }
404
+ }
You can’t perform that action at this time.
0 commit comments