-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c75046
commit 4b5f032
Showing
7 changed files
with
148 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestGetRawPassword(t *testing.T) { | ||
cases := []struct { | ||
args []string | ||
want string | ||
err error | ||
}{ | ||
{[]string{}, "", nil}, | ||
{[]string{""}, "", nil}, | ||
{[]string{"", ""}, "", nil}, | ||
{[]string{"", "dummy"}, "dummy", nil}, | ||
} | ||
|
||
for n, c := range cases { | ||
if got, err := getRawPassword(c.args); c.err == nil && err != nil { | ||
t.Errorf("%d: %s", n, err) | ||
} else if c.err != nil && err == nil { | ||
t.Errorf("%d: no error: %s", n, c.err) | ||
} else if string(got) != c.want { | ||
t.Errorf("%d: want: %s, got: %s", n, c.want, got) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package pgpasswd | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestEncrypt(t *testing.T) { | ||
cases := []struct { | ||
raw []byte | ||
err error | ||
}{ | ||
{[]byte("foo"), nil}, | ||
{[]byte(""), nil}, | ||
{nil, nil}, | ||
} | ||
|
||
for n, c := range cases { | ||
if _, err := Encrypt(c.raw); err != nil && c.err == nil { | ||
t.Errorf("%d: %s", n, err) | ||
} else if err == nil && c.err != nil { | ||
t.Errorf("%d: no error", n) | ||
} | ||
} | ||
} |