-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfo_test.go
More file actions
68 lines (62 loc) · 1.87 KB
/
info_test.go
File metadata and controls
68 lines (62 loc) · 1.87 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
65
66
67
68
// SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company
// SPDX-License-Identifier: Apache-2.0
package liquid
import (
"encoding/json"
"testing"
th "github.com/sapcc/go-api-declarations/internal/testhelper"
. "github.com/majewsky/gg/option"
)
func TestCloneServiceInfo(t *testing.T) {
// this dummy info sets all possible fields in order to test cloning of all levels
info := ServiceInfo{
Version: 42,
DisplayName: "Test Service",
Categories: map[CategoryName]CategoryInfo{
"cat1": {DisplayName: "Category 1"},
"cat2": {DisplayName: "Category 2"},
},
Resources: map[ResourceName]ResourceInfo{
"capacity": {
DisplayName: "Capacity",
Category: Some(CategoryName("cat1")),
Unit: UnitBytes,
Topology: AZAwareTopology,
HasCapacity: true,
NeedsResourceDemand: true,
HasQuota: true,
HandlesCommitments: true,
Attributes: json.RawMessage(`{"foo":"bar"}`),
},
},
Rates: map[RateName]RateInfo{
"thing_creations": {
DisplayName: "Thing Creations",
Category: Some(CategoryName("cat2")),
Unit: UnitNone,
Topology: FlatTopology,
HasUsage: true,
},
},
CapacityMetricFamilies: map[MetricName]MetricFamilyInfo{
"foo_count": {
Type: MetricTypeCounter,
Help: "Counts foo things.",
LabelKeys: []string{"flux_polarization_setting"},
},
},
UsageMetricFamilies: map[MetricName]MetricFamilyInfo{
"bar_count": {
Type: MetricTypeCounter,
Help: "Counts bar things.",
LabelKeys: []string{"phase_shift"},
},
},
UsageReportNeedsProjectMetadata: true,
QuotaUpdateNeedsProjectMetadata: true,
CommitmentHandlingNeedsProjectMetadata: true,
}
clonedInfo := info.Clone()
th.CheckDeepEquals(t, info, clonedInfo)
th.CheckFullySeparate(t, info, clonedInfo)
}