| 1 | // Copyright 2022 Google LLC |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package internalregistry_testscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry_test`/ |
| 16 | |
| 17 | import ( |
| 18 | "testingscip-go gomod github.com/golang/go/src go1.24.0 testing/" |
| 19 | |
| 20 | "github.com/tink-crypto/tink-go/v2/internal/internalregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/" |
| 21 | "github.com/tink-crypto/tink-go/v2/testing/fakemonitoringscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testing/fakemonitoring`/" |
| 22 | ) |
| 23 | |
| 24 | func TestRegisterMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry_test`/TestRegisterMonitoringClient().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 25 | defer internalregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/.ClearMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/ClearMonitoringClient().() |
| 26 | fakeClient := &fakemonitoringscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testing/fakemonitoring`/.Clientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testing/fakemonitoring`/Client#{ |
| 27 | Namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testing/fakemonitoring`/Client#Name.: "fake-monitor-client-1", |
| 28 | } |
| 29 | if err := internalregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/.RegisterMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/RegisterMonitoringClient().(fakeClient); err != nil { |
| 30 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("internalregistry.RegisterMonitoringClient() err = %v, want nil", err) |
| 31 | } |
| 32 | got := internalregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/.GetMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/GetMonitoringClient().().(*fakemonitoringscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testing/fakemonitoring`/.Clientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testing/fakemonitoring`/Client#) |
| 33 | if got.Namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testing/fakemonitoring`/Client#Name. != "fake-monitor-client-1" { |
| 34 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("got = %q, want %q", got.Namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testing/fakemonitoring`/Client#Name., "fake-monitor-client-1") |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | func TestRegisterTwiceFailsMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry_test`/TestRegisterTwiceFailsMonitoringClient().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 39 | defer internalregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/.ClearMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/ClearMonitoringClient().() |
| 40 | fakeClient := fakemonitoringscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testing/fakemonitoring`/.Clientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testing/fakemonitoring`/Client#{} |
| 41 | if err := internalregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/.RegisterMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/RegisterMonitoringClient().(&fakeClient); err != nil { |
| 42 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("internalregistry.RegisterMonitoringClient() err = %v, want nil", err) |
| 43 | } |
| 44 | if err := internalregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/.RegisterMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/RegisterMonitoringClient().(&fakeClient); err == nil { |
| 45 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("internalregistry.RegisterMonitoringClient() err = nil, want error") |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | func TestDefaultMonitoringLoggerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry_test`/TestDefaultMonitoringLogger().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 50 | defaultClient := internalregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/.GetMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/GetMonitoringClient().() |
| 51 | defaultLogger, err := defaultClient.NewLoggerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/monitoring`/Client#NewLogger.(nil) |
| 52 | if err != nil { |
| 53 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("defaultClient.NewLogger() err = %v, want nil", err) |
| 54 | } |
| 55 | defaultLogger.Logscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/monitoring`/Logger#Log.(0, 0) |
| 56 | defaultLogger.LogFailurescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/monitoring`/Logger#LogFailure.() |
| 57 | } |
| 58 | |
| 59 | func TestClearMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry_test`/TestClearMonitoringClient().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 60 | defer internalregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/.ClearMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/ClearMonitoringClient().() |
| 61 | fakeClient := &fakemonitoringscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testing/fakemonitoring`/.Clientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testing/fakemonitoring`/Client#{ |
| 62 | Namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testing/fakemonitoring`/Client#Name.: "fake-monitor-client-1", |
| 63 | } |
| 64 | defaultClient := internalregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/.GetMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/GetMonitoringClient().() |
| 65 | if err := internalregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/.RegisterMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/RegisterMonitoringClient().(fakeClient); err != nil { |
| 66 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("internalregistry.RegisterMonitoringClient() err = %v, want nil", err) |
| 67 | } |
| 68 | got := internalregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/.GetMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/GetMonitoringClient().() |
| 69 | if got != fakeClient { |
| 70 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("internalregistry.GetMonitoringClient() = %v, want %v", got, fakeClient) |
| 71 | } |
| 72 | internalregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/.ClearMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/ClearMonitoringClient().() |
| 73 | got = internalregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/.GetMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/GetMonitoringClient().() |
| 74 | if got != defaultClient { |
| 75 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("internalregistry.GetMonitoringClient() = %v, want %v", got, defaultClient) |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | func TestClearReRegisterMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry_test`/TestClearReRegisterMonitoringClient().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 80 | defer internalregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/.ClearMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/ClearMonitoringClient().() |
| 81 | fakeClient := &fakemonitoringscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testing/fakemonitoring`/.Clientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testing/fakemonitoring`/Client#{ |
| 82 | Namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testing/fakemonitoring`/Client#Name.: "fake-monitor-client-1", |
| 83 | } |
| 84 | if err := internalregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/.RegisterMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/RegisterMonitoringClient().(fakeClient); err != nil { |
| 85 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("internalregistry.RegisterMonitoringClient() err = %v, want nil", err) |
| 86 | } |
| 87 | internalregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/.ClearMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/ClearMonitoringClient().() |
| 88 | fakeClient2 := &fakemonitoringscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testing/fakemonitoring`/.Clientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testing/fakemonitoring`/Client#{ |
| 89 | Namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testing/fakemonitoring`/Client#Name.: "fake-monitor-client-2", |
| 90 | } |
| 91 | if err := internalregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/.RegisterMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/RegisterMonitoringClient().(fakeClient2); err != nil { |
| 92 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("internalregistry.RegisterMonitoringClient() err = %v, want nil", err) |
| 93 | } |
| 94 | got := internalregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/.GetMonitoringClientscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalregistry`/GetMonitoringClient().() |
| 95 | if got != fakeClient2 { |
| 96 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("internalregistry.GetMonitoringClient() = %v, want %v", got, fakeClient2) |
| 97 | } |
| 98 | } |