github.com/aristanetworks/goarista@v0.0.0-20240514173732-cca2755bbd44/gnmi/gnmi_test.go (about)

     1  // Copyright (c) 2021 Arista Networks, Inc.
     2  // Use of this source code is governed by the Apache License 2.0
     3  // that can be found in the COPYING file.
     4  
     5  package gnmi
     6  
     7  import (
     8  	"bytes"
     9  	"crypto/tls"
    10  	"os/exec"
    11  	"regexp"
    12  	"testing"
    13  )
    14  
    15  func TestDependencies(t *testing.T) {
    16  	cmd := exec.Command("go", "list", "-deps")
    17  	out, err := cmd.Output()
    18  	if err != nil {
    19  		t.Fatal(err)
    20  	}
    21  	// Depending on the github.com/aristanetworks/glog is forbidden
    22  	// because this package is often used with
    23  	// github.com/openconfig/... packages which depend on
    24  	// github.com/golang/glog. These two glog packages cannot be used
    25  	// together in one binary because they try to register the same
    26  	// flags.
    27  	if bytes.Contains(out, []byte("github.com/aristanetworks/glog")) {
    28  		t.Error("gnmi depends on github.com/aristanetworks/glog")
    29  	}
    30  }
    31  
    32  func TestTLSVersions(t *testing.T) {
    33  	_ = getTLSVersions(func(u uint16, re *regexp.Regexp) {
    34  		// if we enter this function, it means that there is an issue with the regex matching
    35  		// against a particular version name of TLS, and we need to update the regex to catch
    36  		// this
    37  		t.Fatalf("the regex %s was not sufficient for matching %q,"+
    38  			" please update this regex", re.String(), tls.VersionName(u))
    39  	})
    40  }