-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdomain_test.go
More file actions
64 lines (56 loc) · 1.49 KB
/
Copy pathdomain_test.go
File metadata and controls
64 lines (56 loc) · 1.49 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import "testing"
func TestAssetPrepareRequiresNameAndKind(t *testing.T) {
var asset Asset
if err := asset.Prepare(); err == nil {
t.Fatal("expected missing name error")
}
asset.Name = "Thermal Chamber"
if err := asset.Prepare(); err == nil {
t.Fatal("expected missing kind error")
}
asset.Kind = "environmental_chamber"
if err := asset.Prepare(); err != nil {
t.Fatalf("expected valid asset, got %v", err)
}
if asset.ID == "" {
t.Fatal("expected generated asset id")
}
}
func TestTelemetrySamplePrepareRequiresValue(t *testing.T) {
sample := TelemetrySample{
RunID: "run_1",
ChannelID: "chan_1",
}
if err := sample.Prepare(); err == nil {
t.Fatal("expected missing value error")
}
value := 42.7
sample.NumericValue = &value
if err := sample.Prepare(); err != nil {
t.Fatalf("expected valid sample, got %v", err)
}
if sample.Quality != "good" {
t.Fatalf("expected default quality good, got %q", sample.Quality)
}
if sample.ID == "" {
t.Fatal("expected generated sample id")
}
}
func TestChannelPrepareValidatesDataType(t *testing.T) {
channel := Channel{
AssetID: "asset_1",
Name: "acceleration_x",
DataType: "blob",
}
if err := channel.Prepare(); err == nil {
t.Fatal("expected invalid data type error")
}
channel.DataType = ""
if err := channel.Prepare(); err != nil {
t.Fatalf("expected default data type, got %v", err)
}
if channel.DataType != "float64" {
t.Fatalf("expected float64 data type, got %q", channel.DataType)
}
}