github.com/newrelic/go-agent@v3.26.0+incompatible/internal/cat/path_hash_test.go (about)

     1  // Copyright 2020 New Relic Corporation. All rights reserved.
     2  // SPDX-License-Identifier: Apache-2.0
     3  
     4  package cat
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/newrelic/go-agent/internal/crossagent"
    10  )
    11  
    12  func TestGeneratePathHash(t *testing.T) {
    13  	var tcs []struct {
    14  		Name              string
    15  		ReferringPathHash string
    16  		ApplicationName   string
    17  		TransactionName   string
    18  		ExpectedPathHash  string
    19  	}
    20  
    21  	err := crossagent.ReadJSON("cat/path_hashing.json", &tcs)
    22  	if err != nil {
    23  		t.Fatal(err)
    24  	}
    25  
    26  	for _, tc := range tcs {
    27  		hash, err := GeneratePathHash(tc.ReferringPathHash, tc.TransactionName, tc.ApplicationName)
    28  		if err != nil {
    29  			t.Errorf("%s: error expected to be nil; got %v", tc.Name, err)
    30  		}
    31  		if hash != tc.ExpectedPathHash {
    32  			t.Errorf("%s: expected %s; got %s", tc.Name, tc.ExpectedPathHash, hash)
    33  		}
    34  	}
    35  }