-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
38 lines (32 loc) · 988 Bytes
/
main_test.go
File metadata and controls
38 lines (32 loc) · 988 Bytes
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
package main
import (
"os"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestGetMetadataValue(t *testing.T) {
Convey("Given a metadata file and key", t, func() {
Convey("When the key is found", func() {
Convey("The value is returned", func() {
value, err := getMetadataValue("sample.data", "data_uri")
So(err, ShouldBeNil)
So(value, ShouldEqual, "crate://test/22596363b3de40b06f981fb85d82312e8c0ed511")
})
})
Convey("When the key is not found", func() {
Convey("An error is returned", func() {
key := "jibberish"
_, err := getMetadataValue("sample.data", key)
So(err, ShouldNotBeNil)
So(err.Error(), ShouldEqual, "Unable to find value where key="+key)
})
})
Convey("When the file does not exist", func() {
Convey("An error is returned", func() {
_, err := getMetadataValue("does-not-exist.data", "something")
So(err, ShouldNotBeNil)
So(err, ShouldHaveSameTypeAs, &os.PathError{})
})
})
})
}