Skip to content

Commit 6ed5290

Browse files
authored
Merge pull request kubernetes#90496 from gaurav1086/test_decoder_race_condition
Fix race condition in decoder test
2 parents ef198ec + c6ac8ea commit 6ed5290

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

staging/src/k8s.io/client-go/rest/watch/decoder_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ func TestDecoder(t *testing.T) {
4848
out, in := io.Pipe()
4949

5050
decoder := restclientwatch.NewDecoder(streaming.NewDecoder(out, getDecoder()), getDecoder())
51-
5251
expect := &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo"}}
5352
encoder := json.NewEncoder(in)
53+
eType := eventType
5454
go func() {
5555
data, err := runtime.Encode(scheme.Codecs.LegacyCodec(v1.SchemeGroupVersion), expect)
5656
if err != nil {
5757
t.Fatalf("Unexpected error %v", err)
5858
}
5959
event := metav1.WatchEvent{
60-
Type: string(eventType),
60+
Type: string(eType),
6161
Object: runtime.RawExtension{Raw: json.RawMessage(data)},
6262
}
6363
if err := encoder.Encode(&event); err != nil {
@@ -72,7 +72,7 @@ func TestDecoder(t *testing.T) {
7272
if err != nil {
7373
t.Fatalf("Unexpected error %v", err)
7474
}
75-
if e, a := eventType, action; e != a {
75+
if e, a := eType, action; e != a {
7676
t.Errorf("Expected %v, got %v", e, a)
7777
}
7878
if e, a := expect, got; !apiequality.Semantic.DeepDerivative(e, a) {

0 commit comments

Comments
 (0)