-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhealth_test.go
More file actions
98 lines (78 loc) · 2.52 KB
/
health_test.go
File metadata and controls
98 lines (78 loc) · 2.52 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package gospice
import (
"context"
"os"
"testing"
)
func TestIsSpiceHealthy(t *testing.T) {
t.Run("Local - Health Check", func(t *testing.T) {
spice := NewSpiceClient()
defer func() {
if err := spice.Close(); err != nil {
t.Logf("warning: failed to close SpiceClient: %v", err)
}
}()
if err := spice.Init(WithHttpAddress("http://localhost:8090")); err != nil {
t.Fatalf("error initializing SpiceClient: %v", err)
}
ctx := context.Background()
isHealthy := spice.IsSpiceHealthy(ctx)
// We don't assert true/false since local runtime may not be running
// This test just verifies the method works without errors
t.Logf("Local Spice health status: %v", isHealthy)
})
t.Run("Cloud - Health Check", func(t *testing.T) {
spice := NewSpiceClient()
defer func() {
if err := spice.Close(); err != nil {
t.Logf("warning: failed to close SpiceClient: %v", err)
}
}()
ApiKey, exists := os.LookupEnv("SPICE_API_KEY")
if !exists || ApiKey == "" {
t.Skip("SPICE_API_KEY not set, skipping cloud authentication test")
}
if err := spice.Init(WithApiKey(ApiKey), WithSpiceCloudAddress()); err != nil {
t.Fatalf("error initializing SpiceClient: %v", err)
}
ctx := context.Background()
isHealthy := spice.IsSpiceHealthy(ctx)
t.Logf("Spice Cloud health status: %v", isHealthy)
})
}
func TestIsSpiceReady(t *testing.T) {
t.Run("Cloud - Ready Check", func(t *testing.T) {
spice := NewSpiceClient()
defer func() {
if err := spice.Close(); err != nil {
t.Logf("warning: failed to close SpiceClient: %v", err)
}
}()
ApiKey, exists := os.LookupEnv("SPICE_API_KEY")
if !exists || ApiKey == "" {
t.Skip("SPICE_API_KEY not set, skipping cloud authentication test")
}
if err := spice.Init(WithApiKey(ApiKey), WithSpiceCloudAddress()); err != nil {
t.Fatalf("error initializing SpiceClient: %v", err)
}
ctx := context.Background()
isReady := spice.IsSpiceReady(ctx)
t.Logf("Spice Cloud ready status: %v", isReady)
})
t.Run("Local - Ready Check", func(t *testing.T) {
spice := NewSpiceClient()
defer func() {
if err := spice.Close(); err != nil {
t.Logf("warning: failed to close SpiceClient: %v", err)
}
}()
if err := spice.Init(WithHttpAddress("http://localhost:8090")); err != nil {
t.Fatalf("error initializing SpiceClient: %v", err)
}
ctx := context.Background()
isHealthy := spice.IsSpiceHealthy(ctx)
isReady := spice.IsSpiceReady(ctx)
t.Logf("Local Spice health status: %v", isHealthy)
t.Logf("Local Spice ready status: %v", isReady)
})
}