-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcluster_test.go
66 lines (57 loc) · 2.67 KB
/
cluster_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
/*
* Copyright (c) 2021, 2025 Oracle and/or its affiliates.
* Licensed under the Universal Permissive License v 1.0 as shown at
* https://oss.oracle.com/licenses/upl.
*/
package cmd
import (
"github.com/onsi/gomega"
"github.com/oracle/coherence-go-client/v2/coherence/discovery"
"os"
"testing"
)
func TestValidateTimeout(t *testing.T) {
g := gomega.NewGomegaWithT(t)
g.Expect(validateTimeout(1)).To(gomega.BeNil())
g.Expect(validateTimeout(0)).To(gomega.Not(gomega.BeNil()))
g.Expect(validateTimeout(-1)).To(gomega.Not(gomega.BeNil()))
}
func TestSanitizeConnectionName(t *testing.T) {
g := gomega.NewGomegaWithT(t)
g.Expect(sanitizeConnectionName("$TIM")).To(gomega.Equal("TIM"))
g.Expect(sanitizeConnectionName(",TIM ")).To(gomega.Equal("TIM"))
g.Expect(sanitizeConnectionName("T'IM")).To(gomega.Equal("TIM"))
g.Expect(sanitizeConnectionName("T(IM")).To(gomega.Equal("TIM"))
g.Expect(sanitizeConnectionName("T)IM")).To(gomega.Equal("TIM"))
g.Expect(sanitizeConnectionName("T\"IM")).To(gomega.Equal("TIM"))
g.Expect(sanitizeConnectionName("T[IM")).To(gomega.Equal("TIM"))
g.Expect(sanitizeConnectionName("T]IM")).To(gomega.Equal("TIM"))
g.Expect(sanitizeConnectionName("T\\IM")).To(gomega.Equal("TIM"))
g.Expect(sanitizeConnectionName("T$IM")).To(gomega.Equal("TIM"))
g.Expect(sanitizeConnectionName("T#IM")).To(gomega.Equal("TIM"))
g.Expect(sanitizeConnectionName("T@IM")).To(gomega.Equal("TIM"))
g.Expect(sanitizeConnectionName("T/IM")).To(gomega.Equal("TIM"))
g.Expect(sanitizeConnectionName("T;IM")).To(gomega.Equal("TIM"))
g.Expect(sanitizeConnectionName("T!IM")).To(gomega.Equal("TIM"))
}
func TestFormatCluster(t *testing.T) {
g := gomega.NewGomegaWithT(t)
cluster := discovery.DiscoveredCluster{ClusterName: "tim", Host: "localhost", NSPort: 7574}
g.Expect(formatCluster(cluster)).To(gomega.Equal("Cluster: tim, Name Service address: localhost:7574\n"))
}
func TestGetMavenClasspath(t *testing.T) {
var (
g = gomega.NewGomegaWithT(t)
ce = "com.oracle.coherence.ce"
)
home, _ := os.UserHomeDir()
path, err := getMavenClasspath(ce, "coherence", "14.1.2-0-1", fileTypeJar)
g.Expect(err).To(gomega.BeNil())
g.Expect(path).To(gomega.Equal(home + "/.m2/repository/com/oracle/coherence/ce/coherence/14.1.2-0-1/coherence-14.1.2-0-1.jar"))
path, err = getMavenClasspath(ce, "coherence", "22.09", fileTypeJar)
g.Expect(err).To(gomega.BeNil())
g.Expect(path).To(gomega.Equal(home + "/.m2/repository/com/oracle/coherence/ce/coherence/22.09/coherence-22.09.jar"))
path, err = getMavenClasspath(ce, "coherence", "22.09", fileTypePom)
g.Expect(err).To(gomega.BeNil())
g.Expect(path).To(gomega.Equal(home + "/.m2/repository/com/oracle/coherence/ce/coherence/22.09/coherence-22.09.pom"))
}