github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/util/smalltrace_test.go (about)

     1  // Copyright 2016 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  package util
    12  
    13  import (
    14  	"strings"
    15  	"testing"
    16  )
    17  
    18  // Renumber lines so they're stable no matter what changes above. (We
    19  // could make the regexes accept any string of digits, but we also
    20  // want to make sure that the correct line numbers get captured).
    21  //
    22  //line smalltrace_test.go:1000
    23  
    24  func testSmallTrace2(t *testing.T) {
    25  	s := GetSmallTrace(2)
    26  	if !strings.Contains(s, "smalltrace_test.go:1009:util.testSmallTrace,smalltrace_test.go:1013:util.TestGenerateSmallTrace") {
    27  		t.Fatalf("trace not generated properly: %q", s)
    28  	}
    29  }
    30  
    31  func testSmallTrace(t *testing.T) {
    32  	testSmallTrace2(t)
    33  }
    34  
    35  func TestGenerateSmallTrace(t *testing.T) {
    36  	testSmallTrace(t)
    37  }