Skip to content

Commit

Permalink
Add labels builder tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-hontarau committed Mar 28, 2024
1 parent f17c94c commit e3409db
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions internal/controller/factory/labels_builder_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package factory

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("Labels builder", func() {
Context("When ensuring a labels builder", func() {
It("constructor returns empty initialized map", func() {
builder := NewLabelsBuilder()
Expect(builder).To(Equal(make(LabelsBuilder)))
})
It("WithName sets correct key and value", func() {
builder := NewLabelsBuilder()
builder.WithName()
Expect(builder["app.kubernetes.io/name"]).To(Equal("etcd"))
})
It("WithManagedBy sets correct key and value", func() {
builder := NewLabelsBuilder()
builder.WithManagedBy()
Expect(builder["app.kubernetes.io/managed-by"]).To(Equal("etcd-operator"))
})
It("WithInstance sets correct key and value", func() {
builder := NewLabelsBuilder()
builder.WithInstance("local")
Expect(builder["app.kubernetes.io/instance"]).To(Equal("local"))
})
It("Chaining methods builds correct map", func() {
builder := NewLabelsBuilder()
builder.WithName().WithManagedBy().WithInstance("local")
expected := map[string]string{
"app.kubernetes.io/name": "etcd",
"app.kubernetes.io/instance": "local",
"app.kubernetes.io/managed-by": "etcd-operator",
}
Expect(builder).To(Equal(LabelsBuilder(expected)))
})
})
})

0 comments on commit e3409db

Please sign in to comment.