diff --git a/tests/mock/appcontroller.go b/tests/mock/appcontroller.go new file mode 100644 index 000000000..0d7a9b2d4 --- /dev/null +++ b/tests/mock/appcontroller.go @@ -0,0 +1,27 @@ +package mock + +import ( + "github.com/argoproj-labs/argocd-operator/controllers/argocd/argocdcommon" + "github.com/argoproj-labs/argocd-operator/pkg/util" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +type Appcontroller struct { + Client client.Client + Logger *util.Logger + Name string + Namespace string +} + +func NewAppController(name, namespace string, client client.Client) *Appcontroller { + return &Appcontroller{ + Client: client, + Logger: util.NewLogger("app-controller"), + Name: name, + Namespace: namespace, + } +} + +func (ac *Appcontroller) TriggerRollout(key string) error { + return argocdcommon.TriggerStatefulSetRollout(ac.Name, ac.Namespace, key, ac.Client) +} diff --git a/tests/mock/redis.go b/tests/mock/redis.go new file mode 100644 index 000000000..da0999c42 --- /dev/null +++ b/tests/mock/redis.go @@ -0,0 +1,43 @@ +package mock + +import ( + "github.com/argoproj-labs/argocd-operator/pkg/util" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +type Redis struct { + Client client.Client + Logger *util.Logger + Name string + Namespace string +} + +var ( + useTLS = false + redisServerAddress = "" +) + +func NewRedis(name, namespace string, client client.Client) *Redis { + return &Redis{ + Client: client, + Logger: util.NewLogger("redis"), + Name: name, + Namespace: namespace, + } +} + +func (r *Redis) SetUseTLS(val bool) { + useTLS = val +} + +func (r *Redis) SetServerAddress(val string) { + redisServerAddress = val +} + +func (r *Redis) UseTLS() bool { + return useTLS +} + +func (r *Redis) GetServerAddress() string { + return redisServerAddress +} diff --git a/tests/mock/reposerver.go b/tests/mock/reposerver.go new file mode 100644 index 000000000..1abe7826f --- /dev/null +++ b/tests/mock/reposerver.go @@ -0,0 +1,39 @@ +package mock + +import ( + "github.com/argoproj-labs/argocd-operator/controllers/argocd/argocdcommon" + "github.com/argoproj-labs/argocd-operator/pkg/util" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +type Reposerver struct { + Client client.Client + Logger *util.Logger + Name string + Namespace string +} + +var ( + reposerveraddress = "" +) + +func (r *Reposerver) SetServerAddress(val string) { + reposerveraddress = val +} + +func NewRepoServer(name, namespace string, client client.Client) *Reposerver { + return &Reposerver{ + Client: client, + Logger: util.NewLogger("repo-server"), + Name: name, + Namespace: namespace, + } +} + +func (r *Reposerver) TriggerRollout(key string) error { + return argocdcommon.TriggerDeploymentRollout(r.Name, r.Namespace, key, r.Client) +} + +func (r *Reposerver) GetServerAddress() string { + return reposerveraddress +} diff --git a/tests/mock/server.go b/tests/mock/server.go new file mode 100644 index 000000000..2dab6243e --- /dev/null +++ b/tests/mock/server.go @@ -0,0 +1,27 @@ +package mock + +import ( + "github.com/argoproj-labs/argocd-operator/controllers/argocd/argocdcommon" + "github.com/argoproj-labs/argocd-operator/pkg/util" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +type Server struct { + Client client.Client + Logger *util.Logger + Name string + Namespace string +} + +func NewServer(name, namespace string, client client.Client) *Server { + return &Server{ + Client: client, + Logger: util.NewLogger("server"), + Name: name, + Namespace: namespace, + } +} + +func (s *Server) TriggerRollout(key string) error { + return argocdcommon.TriggerDeploymentRollout(s.Name, s.Namespace, key, s.Client) +}