-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Guy Daich <guy.daich@sap.com>
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright Envoy Gateway Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// The full text of the Apache license is available in the LICENSE file at | ||
// the root of the repo. | ||
|
||
package translator | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
hcmv3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3" | ||
"github.com/stretchr/testify/assert" | ||
"google.golang.org/protobuf/proto" | ||
) | ||
|
||
func Test_toNetworkFilter(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
proto proto.Message | ||
wantErr error | ||
}{ | ||
{ | ||
name: "valid filter", | ||
proto: &hcmv3.HttpConnectionManager{}, | ||
wantErr: nil, | ||
}, | ||
{ | ||
name: "invalid proto msg", | ||
proto: nil, | ||
wantErr: errors.New("empty message received"), | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
_, err := toNetworkFilter("name", tt.proto) | ||
if tt.wantErr != nil { | ||
assert.Equalf(t, tt.wantErr, err, "toNetworkFilter(%v)", tt.proto) | ||
} else { | ||
assert.Equalf(t, nil, err, "toNetworkFilter(%v)", tt.proto) | ||
} | ||
}) | ||
} | ||
} |