File: mock.go

package info (click to toggle)
gitlab-agent 16.1.3-2
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid, trixie
  • size: 6,324 kB
  • sloc: makefile: 175; sh: 52; ruby: 3
file content (36 lines) | stat: -rw-r--r-- 730 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
package k8s

import (
	"context"
)

type MockClient struct {
	NamespaceStore map[string]struct{}
	ApplyRecorder  string
}

func NewMockClient() *MockClient {
	return &MockClient{
		NamespaceStore: map[string]struct{}{},
	}
}

func (m *MockClient) NamespaceExists(ctx context.Context, name string) bool {
	_, ok := m.NamespaceStore[name]
	return ok
}

func (m *MockClient) CreateNamespace(ctx context.Context, name string) error {
	m.NamespaceStore[name] = struct{}{}
	return nil
}

func (m *MockClient) DeleteNamespace(ctx context.Context, name string) error {
	delete(m.NamespaceStore, name)
	return nil
}

func (m *MockClient) Apply(ctx context.Context, namespace, config string) error {
	m.ApplyRecorder = config
	return nil
}