File: common_test.go

package info (click to toggle)
golang-github-mimuret-golang-iij-dpf 0.9.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,340 kB
  • sloc: makefile: 55
file content (66 lines) | stat: -rw-r--r-- 1,591 bytes parent folder | download
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
package common_configs_test

import (
	"github.com/mimuret/golang-iij-dpf/pkg/apis/dpf/v1/common_configs"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("common_configs", func() {
	Context("AttributeMeta", func() {
		var meta common_configs.AttributeMeta
		BeforeEach(func() {
			meta = common_configs.AttributeMeta{}
		})
		Context("GetGroup", func() {
			It("returns name", func() {
				Expect(meta.GetGroup()).To(Equal("common-configs.api.dns-platform.jp/v1"))
			})
		})
		Context("GetCommonConfigID", func() {
			When("default", func() {
				It("returns 0", func() {
					Expect(meta.GetCommonConfigID()).To(Equal(int64(0)))
				})
			})
			When("default", func() {
				BeforeEach(func() {
					meta.CommonConfigID = 1
				})
				It("returns CommonConfigID", func() {
					Expect(meta.GetCommonConfigID()).To(Equal(int64(1)))
				})
			})
		})
		Context("SetCommonConfigID", func() {
			BeforeEach(func() {
				meta.SetCommonConfigID(2)
			})
			It("can set CommonConfigID", func() {
				Expect(meta.GetCommonConfigID()).To(Equal(int64(2)))
			})
		})
		Context("DeepCopy", func() {
			var (
				copy    *common_configs.AttributeMeta
				nilMeta *common_configs.AttributeMeta
			)
			When("AttributeMeta is not nil", func() {
				BeforeEach(func() {
					copy = meta.DeepCopy()
				})
				It("returns copy ", func() {
					Expect(copy).To(Equal(&meta))
				})
			})
			When("AttributeMeta is nil", func() {
				BeforeEach(func() {
					copy = nilMeta.DeepCopy()
				})
				It("returns copy ", func() {
					Expect(copy).To(BeNil())
				})
			})
		})
	})
})