forked from fhirbase/fhirbase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_test.go
37 lines (29 loc) · 928 Bytes
/
load_test.go
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
package main
import (
"fmt"
"strings"
"testing"
)
var fileTypeCases = map[string]bundleType{
"{\"foo\": \"bar\"}\n{\"foo\": \"bar\"}": ndjsonBundleType,
"{\"foo\": \"{{\\\"}bar\"}\n{\"foo\": \"bar\"}": ndjsonBundleType,
"{\"foo\": \"{{\\\"}bar\",\n\n\"resourceType\": \"Bundle\"}": fhirBundleType,
"{\"foo\": \"bar\", \n\n\n\n\n \"resourceType\": \"Observation\"}": singleResourceBundleType,
"{\"foo\": \"{{\\\"}bar\", \"resourceType\": \"Patient\"}": singleResourceBundleType,
}
func TestGuessBundleType(t *testing.T) {
i := 0
for str, tpe := range fileTypeCases {
i++
t.Run(fmt.Sprintf("File type case #%v", str), func(t *testing.T) {
bt, err := guessBundleType(strings.NewReader(str))
if err != nil {
t.Error(err)
}
if bt != tpe {
t.Logf("bundle type not matched (expected %v, got %v)", tpe, bt)
t.Fail()
}
})
}
}