X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=main_test.go;h=35845371f6878e7a44c0de11ad58b8390da48916;hb=d946c291618d93e4ab4ad898c1ae317fbe2256e3;hp=a5c488ee7faa929fd8fe9ad2e38b79d16af407e4;hpb=886b911524a2f14bd7fc76e5a7478e0cfb2fc14d;p=nsscash%2Fnsscash.git diff --git a/main_test.go b/main_test.go index a5c488e..3584537 100644 --- a/main_test.go +++ b/main_test.go @@ -166,8 +166,7 @@ func mustBeOld(t *testing.T, paths ...string) { } mtime := i.ModTime() - now := time.Now() - if now.Sub(mtime) < time.Hour { + if time.Since(mtime) < time.Hour { t.Errorf("%q was recently modified", p) } } @@ -182,8 +181,7 @@ func mustBeNew(t *testing.T, paths ...string) { } mtime := i.ModTime() - now := time.Now() - if now.Sub(mtime) > time.Hour { + if time.Since(mtime) > time.Hour { t.Errorf("%q was not recently modified", p) } } @@ -715,6 +713,7 @@ func fetchStateCannotRead(a args) { statePath+": permission denied") mustNotExist(t, passwdPath, plainPath, groupPath) + mustBeOld(t, statePath) } func fetchStateInvalid(a args) { @@ -889,7 +888,7 @@ password = "%[6]s" err = mainFetch(configPath) mustBeErrorWithSubstring(t, err, "file[0].username/passsword in use and unsafe permissions "+ - "-rw-r--r-- on \"testdata/config.toml\"") + "-rw-r--r-- on \""+configPath+"\"") mustNotExist(t, statePath, groupPath, plainPath) mustBeOld(t, passwdPath)