Skip to content

Commit b058d8e

Browse files
committed
tests(License): The end year in the license file should be current year
1 parent fb19b6a commit b058d8e

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2013-2016 SendGrid, Inc.
3+
Copyright (c) 2013-2017 SendGrid, Inc.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

smtpapi_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import (
44
"encoding/json"
55
"io/ioutil"
66
"reflect"
7+
"regexp"
8+
"strconv"
9+
"strings"
710
"testing"
11+
"time"
812
)
913

1014
func exampleJson() map[string]interface{} {
@@ -369,3 +373,29 @@ func TestMarshalUnmarshall(t *testing.T) {
369373
t.Errorf("Expected %v, but got %v", header, newHeader)
370374
}
371375
}
376+
377+
func TestLicenceDate(t *testing.T) {
378+
b, err := ioutil.ReadFile("./LICENSE.txt")
379+
380+
if err != nil {
381+
t.Fatalf("cannot open license file; got %v", err)
382+
}
383+
384+
r := regexp.MustCompile("(\\d+-\\d+)")
385+
dates := r.FindString(string(b))
386+
387+
if dates == "" {
388+
t.Fatal("cannot find licence date range in the license file")
389+
}
390+
391+
lastDate := strings.Split(dates, "-")[1]
392+
maxLicenseYear, err := strconv.Atoi(lastDate)
393+
394+
if err != nil {
395+
t.Fatalf("cannot convert licence date to int; got %v", err)
396+
}
397+
398+
if maxLicenseYear != time.Now().Year() {
399+
t.Fatalf("end licence year must be %d; got %d", time.Now().Year(), maxLicenseYear)
400+
}
401+
}

0 commit comments

Comments
 (0)