-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f17c94c
commit e3409db
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) | ||
}) | ||
}) | ||
}) |