diff options
author | vitalyisaev <vitalyisaev@ydb.tech> | 2023-12-12 21:55:07 +0300 |
---|---|---|
committer | vitalyisaev <vitalyisaev@ydb.tech> | 2023-12-12 22:25:10 +0300 |
commit | 4967f99474a4040ba150eb04995de06342252718 (patch) | |
tree | c9c118836513a8fab6e9fcfb25be5d404338bca7 /vendor/github.com/aws/smithy-go/middleware/logging_test.go | |
parent | 2ce9cccb9b0bdd4cd7a3491dc5cbf8687cda51de (diff) | |
download | ydb-4967f99474a4040ba150eb04995de06342252718.tar.gz |
YQ Connector: prepare code base for S3 integration
1. Кодовая база Коннектора переписана с помощью Go дженериков так, чтобы добавление нового источника данных (в частности S3 + csv) максимально переиспользовало имеющийся код (чтобы сохранялась логика нарезания на блоки данных, учёт трафика и пр.)
2. API Connector расширено для работы с S3, но ещё пока не протестировано.
Diffstat (limited to 'vendor/github.com/aws/smithy-go/middleware/logging_test.go')
-rw-r--r-- | vendor/github.com/aws/smithy-go/middleware/logging_test.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/vendor/github.com/aws/smithy-go/middleware/logging_test.go b/vendor/github.com/aws/smithy-go/middleware/logging_test.go new file mode 100644 index 0000000000..86c8116ede --- /dev/null +++ b/vendor/github.com/aws/smithy-go/middleware/logging_test.go @@ -0,0 +1,47 @@ +package middleware_test + +import ( + "context" + "io/ioutil" + "testing" + + "github.com/aws/smithy-go/logging" + "github.com/aws/smithy-go/middleware" +) + +type mockWithContextLogger struct { + logging.Logger + Context context.Context +} + +func (m mockWithContextLogger) WithContext(ctx context.Context) logging.Logger { + m.Context = ctx + return m +} + +func TestGetLogger(t *testing.T) { + if logger := middleware.GetLogger(context.Background()); logger == nil { + t.Fatal("expect logger to not be nil") + } else if _, ok := logger.(logging.Nop); !ok { + t.Fatal("expect GetLogger to fallback to Nop") + } + + standardLogger := logging.NewStandardLogger(ioutil.Discard) + ctx := middleware.SetLogger(context.Background(), standardLogger) + + if logger := middleware.GetLogger(ctx); logger == nil { + t.Fatal("expect logger to not be nil") + } else if logger != standardLogger { + t.Error("expect logger to be standard logger") + } + + withContextLogger := mockWithContextLogger{} + ctx = middleware.SetLogger(context.Background(), withContextLogger) + if logger := middleware.GetLogger(ctx); logger == nil { + t.Fatal("expect logger to not be nil") + } else if mock, ok := logger.(mockWithContextLogger); !ok { + t.Error("expect logger to be context logger") + } else if mock.Context != ctx { + t.Error("expect logger context to match") + } +} |