Skip to content
Snippets Groups Projects
Commit 0dc77cde authored by Eric Ju's avatar Eric Ju
Browse files

offloading: Add tests for offloading sink options

This commit adds tests to ensure proper configuration of sink options
when creating a bucket sink. The tests also validate that:
- Default values are correctly set.
- Special cases, such as WithNoRetry(), properly configure the
  configuration as expected.
parent 8fdefe68
No related branches found
No related tags found
Loading
package offloading
import (
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestOffloadingSinkOptions(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
desc string
options []SinkOption
expectedCfg sinkCfg
}{
{
desc: "with default values",
options: []SinkOption{
WithOverallTimout(defaultOverallTimeout),
WithMaxRetry(defaultMaxRetry),
WithRetryTimeout(defaultRetryTimeout),
WithBackoffStrategy(defaultBackoffStrategy),
},
expectedCfg: sinkCfg{
overallTimeout: defaultOverallTimeout,
maxRetry: defaultMaxRetry,
retryTimeout: defaultRetryTimeout,
backoffStrategy: defaultBackoffStrategy,
},
},
{
desc: "with no backoffStrategy",
options: []SinkOption{
WithNoRetry(),
},
expectedCfg: sinkCfg{
maxRetry: 0,
noRetry: true,
},
},
{
desc: "with customized values",
options: []SinkOption{
WithOverallTimout(20 * time.Second),
WithMaxRetry(100),
WithRetryTimeout(2 * time.Second),
WithBackoffStrategy(&backoffStrategyInTest),
},
expectedCfg: sinkCfg{
overallTimeout: 20 * time.Second,
maxRetry: 100,
retryTimeout: 2 * time.Second,
backoffStrategy: &backoffStrategyInTest,
},
},
} {
t.Run(tc.desc, func(t *testing.T) {
cfg := sinkCfg{}
for _, apply := range tc.options {
apply(&cfg)
}
require.Equal(t, tc.expectedCfg, cfg)
})
}
}
package offloading
import (
"testing"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
)
func TestMain(m *testing.M) {
testhelper.Run(m)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment