noop_test.go 792 B

1234567891011121314151617181920212223242526272829303132
  1. package trace
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestNoopSpan_Fork(t *testing.T) {
  8. ctx, span := emptyNoopSpan.Fork(context.Background(), "", "")
  9. assert.Equal(t, emptyNoopSpan, span)
  10. assert.Equal(t, context.Background(), ctx)
  11. }
  12. func TestNoopSpan_Follow(t *testing.T) {
  13. ctx, span := emptyNoopSpan.Follow(context.Background(), "", "")
  14. assert.Equal(t, emptyNoopSpan, span)
  15. assert.Equal(t, context.Background(), ctx)
  16. }
  17. func TestNoopSpan(t *testing.T) {
  18. emptyNoopSpan.Visit(func(key, val string) bool {
  19. assert.Fail(t, "should not go here")
  20. return true
  21. })
  22. ctx, span := emptyNoopSpan.Follow(context.Background(), "", "")
  23. assert.Equal(t, context.Background(), ctx)
  24. assert.Equal(t, "", span.TraceId())
  25. assert.Equal(t, "", span.SpanId())
  26. }