aboutsummaryrefslogtreecommitdiff
path: root/file_test.go
blob: 3bb28e15dc7140530c8714095df6cb5968f7c08a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main

import (
	"bytes"
	"io/ioutil"
	"path"
	"testing"
)

func TestParseFile(t *testing.T) {
	testCases := []string{
		"dim13.sec",
		"dim13.pub",
		"test.sig",
		"kdf.sec",
		"kdf.pub",
	}
	for _, tc := range testCases {
		t.Run(tc, func(t *testing.T) {
			fileName := path.Join("testdata", tc)

			body, err := ioutil.ReadFile(fileName)
			if err != nil {
				t.Error(err)
			}

			f, err := Parse(body)
			if err != nil {
				t.Error(err)
			}

			res, err := f.Bytes()
			if err != nil {
				t.Error(err)
			}

			if !bytes.Equal(res, body) {
				t.Errorf("got %s, want %s", res, body)
			}
		})
	}
}