github.com/lulzWill/go-agent@v2.1.2+incompatible/internal/cat/path_hash_test.go (about)

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