feat: Common runner labels configurable per controller (#327)

* feat: Common runner labels configurable per controller

Ref #321
This commit is contained in:
Yusuke Kuoka
2021-02-18 20:19:08 +09:00
committed by GitHub
parent be13322816
commit 67f6de010b
4 changed files with 71 additions and 6 deletions

View File

@@ -2,6 +2,9 @@ package controllers
import (
"context"
"github.com/google/go-cmp/cmp"
"k8s.io/apimachinery/pkg/runtime"
"testing"
"time"
corev1 "k8s.io/api/core/v1"
@@ -18,6 +21,40 @@ import (
actionsv1alpha1 "github.com/summerwind/actions-runner-controller/api/v1alpha1"
)
func TestNewRunnerReplicaSet(t *testing.T) {
scheme := runtime.NewScheme()
if err := actionsv1alpha1.AddToScheme(scheme); err != nil {
t.Fatalf("%v", err)
}
r := &RunnerDeploymentReconciler{
CommonRunnerLabels: []string{"dev"},
Scheme: scheme,
}
rd := actionsv1alpha1.RunnerDeployment{
ObjectMeta: metav1.ObjectMeta{
Name: "example",
},
Spec: actionsv1alpha1.RunnerDeploymentSpec{
Template: actionsv1alpha1.RunnerTemplate{
Spec: actionsv1alpha1.RunnerSpec{
Labels: []string{"project1"},
},
},
},
}
rs, err := r.newRunnerReplicaSet(rd)
if err != nil {
t.Fatalf("%v", err)
}
want := []string{"project1", "dev"}
if d := cmp.Diff(want, rs.Spec.Template.Spec.Labels); d != "" {
t.Errorf("%s", d)
}
}
// SetupDeploymentTest will set up a testing environment.
// This includes:
// * creating a Namespace to be used during the test