-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
80 lines (72 loc) · 1.48 KB
/
main_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
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright 2024 Carleton University Library All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package main
import (
"encoding/xml"
"os"
"reflect"
"testing"
)
func TestLoadParameters(t *testing.T) {
expectedJob := AlmaJob{
XMLName: xml.Name{
Space: "",
Local: "job",
},
Parameters: []Parameter{
{
Name: DescAndValue{
Value: "task_MmsTaggingParams_boolean",
},
Value: "NONE",
},
{
Name: DescAndValue{
Value: "set_id",
},
Value: "4000000000000",
},
{
Name: DescAndValue{
Value: "job_name",
},
Value: "A Job Name Here",
},
},
}
content := []byte(`<job>
<parameters>
<parameter>
<name>task_MmsTaggingParams_boolean</name>
<value>NONE</value>
</parameter>
<parameter>
<name>set_id</name>
<value>4000000000000</value>
</parameter>
<parameter>
<name>job_name</name>
<value>A Job Name Here</value>
</parameter>
</parameters>
</job>`)
tmpFile, err := os.CreateTemp("", "*.params.xml")
if err != nil {
t.Error(err)
}
defer os.Remove(tmpFile.Name()) // Clean up.
_, err = tmpFile.Write(content)
if err != nil {
tmpFile.Close()
t.Error(err)
}
params, err := LoadParameters(tmpFile.Name())
if err != nil {
t.Error(err)
}
if reflect.DeepEqual(expectedJob, params) == false {
t.Logf("\n%#v\n%#v\n", expectedJob, params)
t.Fatal("Expected job and job loaded through LoadParameters() are not equal.")
}
}