Skip to content

Commit

Permalink
Add test for DROID CSV header output
Browse files Browse the repository at this point in the history
Ensures that the DROID header doesn't change in code unless it
is explicitly made to do so.
  • Loading branch information
ross-spencer committed Feb 5, 2023
1 parent 9f94a77 commit 435c8a8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/writer/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"io/ioutil"
"os"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -156,6 +157,22 @@ matches :
}
}

// TestDroidHeader ensures that the DROID header is output consistently
// and matches the DROID CSV specification.
func TestDroidHeader(t *testing.T) {
buf := &bytes.Buffer{}
droid := Droid(buf)
droid.Head("", time.Time{}, time.Time{}, [3]int{}, [][2]string{{"pronom", ""}}, [][]string{makeFields()}, "md5")
droid.Tail()
// DROID identification result isn't tested here as the paths output
// are absolute and require a bit of finessing in SF to get right.
expected := `ID,PARENT_ID,URI,FILE_PATH,NAME,METHOD,STATUS,SIZE,TYPE,EXT,LAST_MODIFIED,EXTENSION_MISMATCH,MD5_HASH,FORMAT_COUNT,PUID,MIME_TYPE,FORMAT_NAME,FORMAT_VERSION`
res := buf.String()
if strings.Trim(res, "\n") != strings.Trim(expected, "\n") {
t.Errorf("DROID output didn't output as expected: %s %s", res, expected)
}
}

func ExampleYAML() {
yml := YAML(ioutil.Discard)
yml.Head("", time.Time{}, time.Time{}, [3]int{}, [][2]string{{"pronom", ""}}, [][]string{makeFields()}, "")
Expand Down

0 comments on commit 435c8a8

Please sign in to comment.