-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tenant: don't log missing tenant for watchdog
- Loading branch information
1 parent
5cad1d8
commit f5b4fee
Showing
3 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package tenant | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/sourcegraph/zoekt/internal/tenant/tenanttest" | ||
"github.com/sourcegraph/zoekt/trace" | ||
) | ||
|
||
func TestLog(t *testing.T) { | ||
tenanttest.MockEnforce(t) | ||
|
||
cases := []struct { | ||
name string | ||
ctx context.Context | ||
expectedCount int64 | ||
}{ | ||
{ | ||
name: "With Tenant", | ||
ctx: tenanttest.NewTestContext(), | ||
expectedCount: 0, | ||
}, | ||
{ | ||
name: "Skip Logging", | ||
ctx: WithSkipMissingLogging(context.Background()), | ||
expectedCount: 0, | ||
}, | ||
{ | ||
name: "Missing Tenant", | ||
ctx: context.Background(), | ||
expectedCount: 1, | ||
}, | ||
} | ||
|
||
for _, tc := range cases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
tr, ctx := trace.New(tc.ctx, "test", "test") | ||
Log(ctx, tr) | ||
require.Equal(t, tc.expectedCount, pprofUniqID.Load()) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters