2016-02-06 22:54:14 +01:00
|
|
|
package nametransform
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestIsLongName(t *testing.T) {
|
|
|
|
n := "gocryptfs.longname.LkwUdALvV_ANnzQN6ZZMYnxxfARD3IeZWCKnxGJjYmU=.name"
|
2016-04-10 19:32:10 +02:00
|
|
|
if NameType(n) != LongNameFilename {
|
2016-02-06 22:54:14 +01:00
|
|
|
t.Errorf("False negative")
|
|
|
|
}
|
|
|
|
|
|
|
|
n = "gocryptfs.longname.LkwUdALvV_ANnzQN6ZZMYnxxfARD3IeZWCKnxGJjYmU="
|
2016-04-10 19:32:10 +02:00
|
|
|
if NameType(n) != LongNameContent {
|
2016-02-06 22:54:14 +01:00
|
|
|
t.Errorf("False negative")
|
|
|
|
}
|
|
|
|
|
|
|
|
n = "LkwUdALvV_ANnzQN6ZZMYnxxfARD3IeZWCKnxGJjYmU="
|
2016-04-10 19:32:10 +02:00
|
|
|
if NameType(n) != LongNameNone {
|
2016-02-06 22:54:14 +01:00
|
|
|
t.Errorf("False positive")
|
|
|
|
}
|
|
|
|
}
|
2019-02-16 21:55:54 +01:00
|
|
|
|
|
|
|
func TestRemoveLongNameSuffix(t *testing.T) {
|
|
|
|
filename := "gocryptfs.longname.LkwUdALvV_ANnzQN6ZZMYnxxfARD3IeZWCKnxGJjYmU=.name"
|
|
|
|
content := "gocryptfs.longname.LkwUdALvV_ANnzQN6ZZMYnxxfARD3IeZWCKnxGJjYmU="
|
|
|
|
if RemoveLongNameSuffix(filename) != content {
|
|
|
|
t.Error(".name suffix not removed")
|
|
|
|
}
|
|
|
|
}
|