(client kubernetes.Interface)
| 24 | const testNamespace = "test" |
| 25 | |
| 26 | func createTestResources(client kubernetes.Interface) error { |
| 27 | podMetadata := metav1.ObjectMeta{ |
| 28 | Name: "test-pod", |
| 29 | Labels: map[string]string{ |
| 30 | "app.kubernetes.io/name": "devspace-app", |
| 31 | }, |
| 32 | } |
| 33 | podSpec := v1.PodSpec{ |
| 34 | Containers: []v1.Container{ |
| 35 | { |
| 36 | Name: "test", |
| 37 | Image: "nginx", |
| 38 | }, |
| 39 | }, |
| 40 | } |
| 41 | |
| 42 | deploy := &v1beta1.Deployment{ |
| 43 | ObjectMeta: metav1.ObjectMeta{Name: "test-deployment"}, |
| 44 | Spec: v1beta1.DeploymentSpec{ |
| 45 | Replicas: ptr.Int32(1), |
| 46 | Selector: &metav1.LabelSelector{ |
| 47 | MatchLabels: map[string]string{ |
| 48 | "app.kubernetes.io/name": "devspace-app", |
| 49 | }, |
| 50 | }, |
| 51 | Template: v1.PodTemplateSpec{ |
| 52 | ObjectMeta: podMetadata, |
| 53 | Spec: podSpec, |
| 54 | }, |
| 55 | }, |
| 56 | Status: v1beta1.DeploymentStatus{ |
| 57 | AvailableReplicas: 1, |
| 58 | ObservedGeneration: 1, |
| 59 | ReadyReplicas: 1, |
| 60 | Replicas: 1, |
| 61 | UpdatedReplicas: 1, |
| 62 | }, |
| 63 | } |
| 64 | _, err := client.AppsV1().Deployments(testNamespace).Create(context.TODO(), deploy, metav1.CreateOptions{}) |
| 65 | if err != nil { |
| 66 | return errors.Wrap(err, "create deployment") |
| 67 | } |
| 68 | |
| 69 | p := &v1.Pod{ |
| 70 | ObjectMeta: podMetadata, |
| 71 | Spec: podSpec, |
| 72 | Status: v1.PodStatus{ |
| 73 | Phase: v1.PodRunning, |
| 74 | ContainerStatuses: []v1.ContainerStatus{ |
| 75 | { |
| 76 | Name: "test", |
| 77 | Ready: true, |
| 78 | Image: "nginx", |
| 79 | State: v1.ContainerState{ |
| 80 | Running: &v1.ContainerStateRunning{ |
| 81 | StartedAt: metav1.NewTime(time.Now()), |
| 82 | }, |
| 83 | }, |
no test coverage detected