Skip to content

Commit

Permalink
Test ensureTrustedDir
Browse files Browse the repository at this point in the history
  • Loading branch information
Oskar Sharipov committed Jul 22, 2022
1 parent 4634fc5 commit 6c2e3d7
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions minitrust_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package minitrust

import (
"os"
"path/filepath"
"testing"

"github.com/jedisct1/go-minisign"
Expand All @@ -9,6 +11,34 @@ import (
const rawPubKey = "RWRWfuqg9DPmJzteqVmj5xSm7z1V0ZTNA66UGpF+5vdkUe8llEMWkC6n"
const pubKeyID = "27E633F4A0EA7E56"

func mkdirTempHome(t *testing.T) string {
dir, err := os.MkdirTemp("", "test-minitrust-*")
if err != nil {
t.Fatal(err)
}
return dir
}

func TestEnsureTrustedDir(t *testing.T) {
dir := mkdirTempHome(t)
defer os.RemoveAll(dir)

for _, test := range []string{
dir,
filepath.Join(dir, "whataboutthis"),
filepath.Join(dir, "foo", "bar"),
} {
err := ensureTrustedDir(test)
if err != nil {
t.Fatal(err)
}
_, err = os.Stat(test)
if err != nil {
t.Fatal(err)
}
}
}

func TestEncodePublicKey(t *testing.T) {
pk, err := minisign.NewPublicKey(rawPubKey)
if err != nil {
Expand Down

0 comments on commit 6c2e3d7

Please sign in to comment.