Skip to content

Commit

Permalink
flag description and test naming
Browse files Browse the repository at this point in the history
Signed-off-by: Ed Snible <snible@us.ibm.com>
  • Loading branch information
esnible committed May 25, 2022
1 parent e4cdb6b commit 0c79158
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
39 changes: 22 additions & 17 deletions cmd/collector/app/handler/grpc_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,17 +254,20 @@ func TestPostTenantedSpans(t *testing.T) {
},
}
for _, test := range tests {
_, err := client.PostSpans(test.ctx, &api_v2.PostSpansRequest{
Batch: test.batch,
t.Run(test.name, func(t *testing.T) {

_, err := client.PostSpans(test.ctx, &api_v2.PostSpansRequest{
Batch: test.batch,
})
if test.mustFail {
require.Error(t, err)
} else {
require.NoError(t, err)
}
assert.Equal(t, test.expected, processor.getSpans())
assert.Equal(t, test.expectedTenants, processor.getTenants())
processor.reset()
})
if test.mustFail {
require.Error(t, err, "test: %s", test.name)
} else {
require.NoError(t, err, "test: %s", test.name)
}
assert.Equal(t, test.expected, processor.getSpans(), "test: %s", test.name)
assert.Equal(t, test.expectedTenants, processor.getTenants(), "test: %s", test.name)
processor.reset()
}
}

Expand Down Expand Up @@ -323,12 +326,14 @@ func TestGetTenant(t *testing.T) {
Tenants: validTenants,
}))
for _, test := range tests {
tenant, err := handler.validateTenant(test.ctx)
if test.mustFail {
require.Error(t, err, "test: %s", test.name)
} else {
require.NoError(t, err, "test: %s", test.name)
}
assert.Equal(t, test.tenant, tenant, "test: %s", test.name)
t.Run(test.name, func(t *testing.T) {
tenant, err := handler.validateTenant(test.ctx)
if test.mustFail {
require.Error(t, err)
} else {
require.NoError(t, err)
}
assert.Equal(t, test.tenant, tenant)
})
}
}
5 changes: 4 additions & 1 deletion pkg/config/tenancy/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package tenancy

import (
"flag"
"fmt"
"strings"

"github.com/spf13/viper"
Expand All @@ -31,7 +32,9 @@ const (
func AddFlags(flags *flag.FlagSet) {
flags.Bool(tenancyEnabled, false, "Enable tenancy header when receiving or querying")
flags.String(tenancyHeader, "x-tenant", "HTTP header carrying tenant")
flags.String(validTenants, "", "Acceptable tenants")
flags.String(validTenants, "",
fmt.Sprintf("comma-separated list of allowed values for --%s header. (If not supplied, tenants are not restricted)",
tenancyHeader))
}

// InitFromViper creates tenancy.Options populated with values retrieved from Viper.
Expand Down

0 comments on commit 0c79158

Please sign in to comment.