1
mirror of https://github.com/rclone/rclone synced 2024-11-21 22:50:16 +01:00

Add tests for reveal functions

This commit is contained in:
Andres Alvarez 2018-08-06 20:01:34 +02:00 committed by Nick Craig-Wood
parent 8989c367c4
commit c1f5add049

View File

@ -36,3 +36,25 @@ func TestObscure(t *testing.T) {
}
}
func TestReveal(t *testing.T) {
for _, test := range []struct {
in string
want string
iv string
}{
{"YWFhYWFhYWFhYWFhYWFhYQ", "", "aaaaaaaaaaaaaaaa"},
{"YWFhYWFhYWFhYWFhYWFhYXMaGgIlEQ", "potato", "aaaaaaaaaaaaaaaa"},
{"YmJiYmJiYmJiYmJiYmJiYp3gcEWbAw", "potato", "bbbbbbbbbbbbbbbb"},
} {
cryptRand = bytes.NewBufferString(test.iv)
got, err := Reveal(test.in)
assert.NoError(t, err)
assert.Equal(t, test.want, got)
// Now the Must variants
cryptRand = bytes.NewBufferString(test.iv)
got = MustReveal(test.in)
assert.Equal(t, test.want, got)
}
}