distribusi-go/distribusi_test.go
decentral1se b9272e7a61
All checks were successful
continuous-integration/drone Build is passing
refactor!: v2
2024-07-23 21:40:45 +02:00

36 lines
760 B
Go

package main
import (
"testing"
)
func TestTrimAllNewlines(t *testing.T) {
trimmed := trimAllNewlines("\nfoo\n")
if trimmed != "foo" {
t.Fatalf("failed to trimmed new line from '\\nfoo\\n'")
}
}
func TestParseMtype(t *testing.T) {
mtype := "os/directory"
ftype, stype, err := parseMtype(mtype)
if ftype != "os" || stype != "directory" {
t.Fatalf("unable to parse %s", mtype)
}
mtype = "image/gif; charset=utf-8"
ftype, stype, err = parseMtype(mtype)
if err != nil {
t.Fatalf("failed to parse %s", mtype)
}
if ftype != "image" || stype != "gif" {
t.Fatalf("unable to parse %s", mtype)
}
mtype = "notamimetype"
ftype, stype, err = parseMtype(mtype)
if err == nil {
t.Fatalf("failed to error out correctly parsing %s", mtype)
}
}