@@ -2,9 +2,9 @@ package test
2
2
3
3
import (
4
4
"context"
5
- "fmt"
6
5
"os"
7
6
"sync"
7
+ "testing"
8
8
9
9
"github.com/otto-de/sherlock-microservice/pkg/gke"
10
10
core "k8s.io/api/core/v1"
@@ -25,16 +25,16 @@ type PodRun struct {
25
25
26
26
// NewPodRun is starting a remote Pod and streams its output locally.
27
27
// Output gets written using provided streams.
28
- func NewPodRunWithStreams (clientset * kubernetes.Clientset , ctx context.Context , pod * core.Pod , streams genericclioptions.IOStreams ) * PodRun {
28
+ func NewPodRunWithStreams (tb testing. TB , clientset * kubernetes.Clientset , ctx context.Context , pod * core.Pod , streams genericclioptions.IOStreams ) * PodRun {
29
29
30
30
pods := clientset .CoreV1 ().Pods (pod .Namespace )
31
31
32
- fmt . Fprintln ( streams . Out , "Creating Test Pod" )
32
+ tb . Log ( "Creating Test Pod\n " )
33
33
pod , err := pods .Create (ctx , pod , metav1.CreateOptions {})
34
34
if err != nil {
35
35
panic (err )
36
36
}
37
- fmt . Fprintf ( streams . Out , "Created Test Pod `%s`\n " , pod .Name )
37
+ tb . Logf ( "Created Test Pod `%s`\n " , pod .Name )
38
38
39
39
pr := & PodRun {
40
40
ctx : ctx ,
@@ -56,19 +56,19 @@ func NewPodRunWithStreams(clientset *kubernetes.Clientset, ctx context.Context,
56
56
57
57
// NewPodRun is starting a remote Pod and streams its output locally.
58
58
// Output gets written to Stdout and Stderr.
59
- func NewPodRun (clientset * kubernetes.Clientset , ctx context.Context , pod * core.Pod ) * PodRun {
59
+ func NewPodRun (tb testing. TB , clientset * kubernetes.Clientset , ctx context.Context , pod * core.Pod ) * PodRun {
60
60
61
61
streams := genericclioptions.IOStreams {
62
62
In : nil ,
63
63
Out : os .Stdout ,
64
64
ErrOut : os .Stderr ,
65
65
}
66
- return NewPodRunWithStreams (clientset , ctx , pod , streams )
66
+ return NewPodRunWithStreams (tb , clientset , ctx , pod , streams )
67
67
}
68
68
69
69
// Close waits until there is no more output to stream. Then deletes the Pod.
70
- func (pr * PodRun ) Close () error {
70
+ func (pr * PodRun ) Close (tb testing. TB ) error {
71
71
pr .logStreaming .Wait ()
72
- fmt . Fprintf ( pr . streams . Out , "Deleting Test Pod `%s`\n " , pr .Pod .Name )
72
+ tb . Logf ( "Deleting Test Pod `%s`\n " , pr .Pod .Name )
73
73
return pr .pods .Delete (pr .ctx , pr .Pod .Name , metav1.DeleteOptions {})
74
74
}
0 commit comments