Skip to content

Commit

Permalink
tests(etcdserver): refactor
Browse files Browse the repository at this point in the history
Signed-off-by: wafuwafu13 <[email protected]>
  • Loading branch information
wafuwafu13 committed Dec 16, 2022
1 parent 8dcfca0 commit 2ffa9e7
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions server/etcdserver/server_access_control_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016 The etcd Authors
// Copyright 2022 The etcd Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,11 @@

package etcdserver

import "testing"
import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestOriginAllowed(t *testing.T) {
tests := []struct {
Expand Down Expand Up @@ -59,16 +63,14 @@ func TestOriginAllowed(t *testing.T) {
},
}

for i, tt := range tests {
for _, tt := range tests {
allowed := tt.accessController.OriginAllowed(tt.origin)
if allowed != tt.allowed {
t.Fatalf("#%d: allowd = %t, want %t", i, allowed, tt.allowed)
}
assert.Equal(t, allowed, tt.allowed)
}
}

func TestIsHostWhitelisted(t *testing.T) {
tests := []struct{
tests := []struct {
accessController *AccessController
host string
whitelisted bool
Expand Down Expand Up @@ -110,10 +112,8 @@ func TestIsHostWhitelisted(t *testing.T) {
},
}

for i, tt := range tests {
for _, tt := range tests {
whitelisted := tt.accessController.IsHostWhitelisted(tt.host)
if whitelisted != tt.whitelisted {
t.Fatalf("#%d:whitelisted = %t, want %t", i, whitelisted, tt.whitelisted)
}
assert.Equal(t, whitelisted, tt.whitelisted)
}
}

0 comments on commit 2ffa9e7

Please sign in to comment.