...

Source file src/github.com/datawire/ambassador/v2/pkg/envoy-control-plane/cache/v3/status_test.go

Documentation: github.com/datawire/ambassador/v2/pkg/envoy-control-plane/cache/v3

     1  // Code generated by create_version. DO NOT EDIT.
     2  // Copyright 2018 Envoyproxy Authors
     3  //
     4  //   Licensed under the Apache License, Version 2.0 (the "License");
     5  //   you may not use this file except in compliance with the License.
     6  //   You may obtain a copy of the License at
     7  //
     8  //       http://www.apache.org/licenses/LICENSE-2.0
     9  //
    10  //   Unless required by applicable law or agreed to in writing, software
    11  //   distributed under the License is distributed on an "AS IS" BASIS,
    12  //   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  //   See the License for the specific language governing permissions and
    14  //   limitations under the License.
    15  
    16  package cache
    17  
    18  import (
    19  	"reflect"
    20  	"testing"
    21  
    22  	core "github.com/datawire/ambassador/v2/pkg/api/envoy/config/core/v3"
    23  )
    24  
    25  func TestIDHash(t *testing.T) {
    26  	node := &core.Node{Id: "test"}
    27  	if got := (IDHash{}).ID(node); got != "test" {
    28  		t.Errorf("IDHash.ID(%v) => got %s, want %s", node, got, node.Id)
    29  	}
    30  	if got := (IDHash{}).ID(nil); got != "" {
    31  		t.Errorf("IDHash.ID(nil) => got %s, want empty", got)
    32  	}
    33  }
    34  
    35  func TestNewStatusInfo(t *testing.T) {
    36  	node := &core.Node{Id: "test"}
    37  	info := newStatusInfo(node)
    38  
    39  	if got := info.GetNode(); !reflect.DeepEqual(got, node) {
    40  		t.Errorf("GetNode() => got %#v, want %#v", got, node)
    41  	}
    42  
    43  	if got := info.GetNumWatches(); got != 0 {
    44  		t.Errorf("GetNumWatches() => got %d, want 0", got)
    45  	}
    46  
    47  	if got := info.GetLastWatchRequestTime(); !got.IsZero() {
    48  		t.Errorf("GetLastWatchRequestTime() => got %v, want zero time", got)
    49  	}
    50  
    51  }
    52  

View as plain text