From 59ba8ac43a33619e84b2ba912b90f0f5fce40deb Mon Sep 17 00:00:00 2001 From: Pasquale Congiusti Date: Fri, 8 Jan 2021 11:39:15 +0100 Subject: [PATCH] feat(test): delete command unit test * Added a suite of test to check flags available for delete command * Refactored install_test.go to avoid clash with delete method names Closes #1157 --- pkg/cmd/delete_test.go | 34 ++++++- pkg/cmd/install_test.go | 198 ++++++++++++++++++++-------------------- 2 files changed, 129 insertions(+), 103 deletions(-) diff --git a/pkg/cmd/delete_test.go b/pkg/cmd/delete_test.go index b66604ced7..cd422ee1ab 100644 --- a/pkg/cmd/delete_test.go +++ b/pkg/cmd/delete_test.go @@ -18,20 +18,46 @@ limitations under the License. package cmd import ( + "testing" + "github.com/apache/camel-k/pkg/util/test" "github.com/spf13/cobra" + "github.com/stretchr/testify/assert" ) -//nolint:deadcode,unused +const cmdDelete = "delete" + +func initializeDeleteCmdOptions(t *testing.T) (*deleteCmdOptions, *cobra.Command, RootCmdOptions) { + options, rootCmd := kamelTestPreAddCommandInit() + deleteCmdOptions := addTestDeleteCmd(*options, rootCmd) + kamelTestPostAddCommandInit(t, rootCmd) + + return deleteCmdOptions, rootCmd, *options +} + func addTestDeleteCmd(options RootCmdOptions, rootCmd *cobra.Command) *deleteCmdOptions { //add a testing version of delete Command - deleteCmd, deleteCmdOptions := newCmdDelete(&options) + deleteCmd, deleteOptions := newCmdDelete(&options) deleteCmd.RunE = func(c *cobra.Command, args []string) error { return nil } + deleteCmd.PostRunE = func(c *cobra.Command, args []string) error { + return nil + } deleteCmd.Args = test.ArbitraryArgs rootCmd.AddCommand(deleteCmd) - return deleteCmdOptions + return deleteOptions } -//TODO: add a proper test, take inspiration by run_test.go +func TestDeleteNonExistingFlag(t *testing.T) { + _, rootCmd, _ := initializeDeleteCmdOptions(t) + _, err := test.ExecuteCommand(rootCmd, cmdDelete, "--nonExistingFlag") + assert.NotNil(t, err) +} + +func TestDeleteAllFlag(t *testing.T) { + deleteCmdOptions, rootCmd, _ := initializeDeleteCmdOptions(t) + _, err := test.ExecuteCommand(rootCmd, cmdDelete, "--all") + assert.Nil(t, err) + assert.Equal(t, true, deleteCmdOptions.DeleteAll) +} diff --git a/pkg/cmd/install_test.go b/pkg/cmd/install_test.go index 5228170876..157430cb0e 100644 --- a/pkg/cmd/install_test.go +++ b/pkg/cmd/install_test.go @@ -31,12 +31,12 @@ import ( const cmdInstall = "install" -func initializeRunCmdOptions(t *testing.T) (*installCmdOptions, *cobra.Command, RootCmdOptions) { +func initializeInstallCmdOptions(t *testing.T) (*installCmdOptions, *cobra.Command, RootCmdOptions) { options, rootCmd := kamelTestPreAddCommandInit() - runCmdOptions := addTestInstallCmd(*options, rootCmd) + installCmdOptions := addTestInstallCmd(*options, rootCmd) kamelTestPostAddCommandInit(t, rootCmd) - return runCmdOptions, rootCmd, *options + return installCmdOptions, rootCmd, *options } func addTestInstallCmd(options RootCmdOptions, rootCmd *cobra.Command) *installCmdOptions { @@ -54,163 +54,163 @@ func addTestInstallCmd(options RootCmdOptions, rootCmd *cobra.Command) *installC } func TestInstallNoFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall) assert.Nil(t, err) //Check default expected values - assert.Equal(t, false, runCmdOptions.Wait) - assert.Equal(t, false, runCmdOptions.ClusterSetupOnly) - assert.Equal(t, false, runCmdOptions.SkipOperatorSetup) - assert.Equal(t, false, runCmdOptions.SkipClusterSetup) - assert.Equal(t, false, runCmdOptions.ExampleSetup) - assert.Equal(t, false, runCmdOptions.Global) - assert.Equal(t, false, runCmdOptions.KanikoBuildCache) - assert.Equal(t, false, runCmdOptions.Save) - assert.Equal(t, false, runCmdOptions.Force) - assert.Equal(t, true, runCmdOptions.Olm) - assert.Equal(t, olm.DefaultOperatorName, runCmdOptions.olmOptions.OperatorName) - assert.Equal(t, olm.DefaultPackage, runCmdOptions.olmOptions.Package) - assert.Equal(t, olm.DefaultChannel, runCmdOptions.olmOptions.Channel) - assert.Equal(t, olm.DefaultSource, runCmdOptions.olmOptions.Source) - assert.Equal(t, olm.DefaultSourceNamespace, runCmdOptions.olmOptions.SourceNamespace) - assert.Equal(t, olm.DefaultGlobalNamespace, runCmdOptions.olmOptions.GlobalNamespace) - assert.Equal(t, int32(8081), runCmdOptions.HealthPort) - assert.Equal(t, false, runCmdOptions.Monitoring) - assert.Equal(t, int32(8080), runCmdOptions.MonitoringPort) + assert.Equal(t, false, installCmdOptions.Wait) + assert.Equal(t, false, installCmdOptions.ClusterSetupOnly) + assert.Equal(t, false, installCmdOptions.SkipOperatorSetup) + assert.Equal(t, false, installCmdOptions.SkipClusterSetup) + assert.Equal(t, false, installCmdOptions.ExampleSetup) + assert.Equal(t, false, installCmdOptions.Global) + assert.Equal(t, false, installCmdOptions.KanikoBuildCache) + assert.Equal(t, false, installCmdOptions.Save) + assert.Equal(t, false, installCmdOptions.Force) + assert.Equal(t, true, installCmdOptions.Olm) + assert.Equal(t, olm.DefaultOperatorName, installCmdOptions.olmOptions.OperatorName) + assert.Equal(t, olm.DefaultPackage, installCmdOptions.olmOptions.Package) + assert.Equal(t, olm.DefaultChannel, installCmdOptions.olmOptions.Channel) + assert.Equal(t, olm.DefaultSource, installCmdOptions.olmOptions.Source) + assert.Equal(t, olm.DefaultSourceNamespace, installCmdOptions.olmOptions.SourceNamespace) + assert.Equal(t, olm.DefaultGlobalNamespace, installCmdOptions.olmOptions.GlobalNamespace) + assert.Equal(t, int32(8081), installCmdOptions.HealthPort) + assert.Equal(t, false, installCmdOptions.Monitoring) + assert.Equal(t, int32(8080), installCmdOptions.MonitoringPort) } func TestInstallNonExistingFlag(t *testing.T) { - _, rootCmd, _ := initializeRunCmdOptions(t) + _, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--nonExistingFlag") assert.NotNil(t, err) } func TestInstallBaseImageFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--base-image", "someString") assert.Nil(t, err) - assert.Equal(t, "someString", runCmdOptions.BaseImage) + assert.Equal(t, "someString", installCmdOptions.BaseImage) } func TestInstallBuildPublishStrategyFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--build-publish-strategy", "someString") assert.Nil(t, err) - assert.Equal(t, "someString", runCmdOptions.BuildPublishStrategy) + assert.Equal(t, "someString", installCmdOptions.BuildPublishStrategy) } func TestInstallBuildStrategyFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--build-strategy", "someString") assert.Nil(t, err) - assert.Equal(t, "someString", runCmdOptions.BuildStrategy) + assert.Equal(t, "someString", installCmdOptions.BuildStrategy) } func TestInstallBuildTimeoutFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--build-timeout", "10") assert.Nil(t, err) - assert.Equal(t, "10", runCmdOptions.BuildTimeout) + assert.Equal(t, "10", installCmdOptions.BuildTimeout) } func TestInstallClusterSetupFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--cluster-setup") assert.Nil(t, err) - assert.Equal(t, true, runCmdOptions.ClusterSetupOnly) + assert.Equal(t, true, installCmdOptions.ClusterSetupOnly) } func TestInstallClusterTypeFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--cluster-type", "Kubernetes") assert.Nil(t, err) - assert.Equal(t, "Kubernetes", runCmdOptions.ClusterType) + assert.Equal(t, "Kubernetes", installCmdOptions.ClusterType) } func TestInstallExampleFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--example") assert.Nil(t, err) - assert.Equal(t, true, runCmdOptions.ExampleSetup) + assert.Equal(t, true, installCmdOptions.ExampleSetup) } func TestInstallForceFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--force") assert.Nil(t, err) - assert.Equal(t, true, runCmdOptions.Force) + assert.Equal(t, true, installCmdOptions.Force) } func TestInstallGlobalFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--global") assert.Nil(t, err) - assert.Equal(t, true, runCmdOptions.Global) + assert.Equal(t, true, installCmdOptions.Global) } func TestInstallHealthFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--health-port", "7777") assert.Nil(t, err) - assert.Equal(t, int32(7777), runCmdOptions.HealthPort) + assert.Equal(t, int32(7777), installCmdOptions.HealthPort) } func TestInstallHttpProxySecretFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--http-proxy-secret", "someString") assert.Nil(t, err) - assert.Equal(t, "someString", runCmdOptions.HTTPProxySecret) + assert.Equal(t, "someString", installCmdOptions.HTTPProxySecret) } func TestInstallKanikoBuildCacheFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--kaniko-build-cache") assert.Nil(t, err) - assert.Equal(t, true, runCmdOptions.KanikoBuildCache) + assert.Equal(t, true, installCmdOptions.KanikoBuildCache) } func TestInstallLocalRepositoryFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--local-repository", "someString") assert.Nil(t, err) - assert.Equal(t, "someString", runCmdOptions.LocalRepository) + assert.Equal(t, "someString", installCmdOptions.LocalRepository) } func TestInstallMavenRepositoryFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--maven-repository", "someString1", "--maven-repository", "someString2") assert.Nil(t, err) - assert.Equal(t, "someString1", runCmdOptions.MavenRepositories[0]) - assert.Equal(t, "someString2", runCmdOptions.MavenRepositories[1]) + assert.Equal(t, "someString1", installCmdOptions.MavenRepositories[0]) + assert.Equal(t, "someString2", installCmdOptions.MavenRepositories[1]) } func TestInstallMavenSettingsFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--maven-settings", "someString") assert.Nil(t, err) - assert.Equal(t, "someString", runCmdOptions.MavenSettings) + assert.Equal(t, "someString", installCmdOptions.MavenSettings) } func TestInstallMonitoringFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--monitoring", "--monitoring-port", "7777") assert.Nil(t, err) - assert.Equal(t, true, runCmdOptions.Monitoring) - assert.Equal(t, int32(7777), runCmdOptions.MonitoringPort) + assert.Equal(t, true, installCmdOptions.Monitoring) + assert.Equal(t, int32(7777), installCmdOptions.MonitoringPort) } func TestInstallOlmFalseFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--olm=false") assert.Nil(t, err) - assert.Equal(t, false, runCmdOptions.Olm) + assert.Equal(t, false, installCmdOptions.Olm) } func TestInstallOlmTrueNonDefaultFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--olm", "--olm-channel", "olmChannel", "--olm-global-namespace", "olmGlobalNamespace", @@ -220,113 +220,113 @@ func TestInstallOlmTrueNonDefaultFlag(t *testing.T) { "--olm-source-namespace", "olmSourceNamespace", "--olm-starting-csv", "olmStartingCSV") assert.Nil(t, err) - assert.Equal(t, true, runCmdOptions.Olm) - assert.Equal(t, "olmChannel", runCmdOptions.olmOptions.Channel) - assert.Equal(t, "olmGlobalNamespace", runCmdOptions.olmOptions.GlobalNamespace) - assert.Equal(t, "olmOperatorName", runCmdOptions.olmOptions.OperatorName) - assert.Equal(t, "olmPackage", runCmdOptions.olmOptions.Package) - assert.Equal(t, "olmSource", runCmdOptions.olmOptions.Source) - assert.Equal(t, "olmSourceNamespace", runCmdOptions.olmOptions.SourceNamespace) - assert.Equal(t, "olmStartingCSV", runCmdOptions.olmOptions.StartingCSV) + assert.Equal(t, true, installCmdOptions.Olm) + assert.Equal(t, "olmChannel", installCmdOptions.olmOptions.Channel) + assert.Equal(t, "olmGlobalNamespace", installCmdOptions.olmOptions.GlobalNamespace) + assert.Equal(t, "olmOperatorName", installCmdOptions.olmOptions.OperatorName) + assert.Equal(t, "olmPackage", installCmdOptions.olmOptions.Package) + assert.Equal(t, "olmSource", installCmdOptions.olmOptions.Source) + assert.Equal(t, "olmSourceNamespace", installCmdOptions.olmOptions.SourceNamespace) + assert.Equal(t, "olmStartingCSV", installCmdOptions.olmOptions.StartingCSV) } func TestInstallOperatorImageFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--operator-image", "someString") assert.Nil(t, err) - assert.Equal(t, "someString", runCmdOptions.OperatorImage) + assert.Equal(t, "someString", installCmdOptions.OperatorImage) } func TestInstallOperatorImagePullPolicyFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--operator-image-pull-policy", "someString") assert.Nil(t, err) - assert.Equal(t, "someString", runCmdOptions.OperatorImagePullPolicy) + assert.Equal(t, "someString", installCmdOptions.OperatorImagePullPolicy) } func TestInstallOutputFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--output", "yaml") assert.Nil(t, err) - assert.Equal(t, "yaml", runCmdOptions.OutputFormat) + assert.Equal(t, "yaml", installCmdOptions.OutputFormat) } func TestInstallPropertyFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--property", "someString1", "--property", "someString2") assert.Nil(t, err) - assert.Equal(t, "someString1", runCmdOptions.Properties[0]) - assert.Equal(t, "someString2", runCmdOptions.Properties[1]) + assert.Equal(t, "someString1", installCmdOptions.Properties[0]) + assert.Equal(t, "someString2", installCmdOptions.Properties[1]) } func TestInstallRegistryFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--registry", "registry", "--organization", "organization", "--registry-insecure", "--registry-secret", "secret") assert.Nil(t, err) - assert.Equal(t, "registry", runCmdOptions.registry.Address) - assert.Equal(t, "organization", runCmdOptions.registry.Organization) - assert.Equal(t, true, runCmdOptions.registry.Insecure) - assert.Equal(t, "secret", runCmdOptions.registry.Secret) + assert.Equal(t, "registry", installCmdOptions.registry.Address) + assert.Equal(t, "organization", installCmdOptions.registry.Organization) + assert.Equal(t, true, installCmdOptions.registry.Insecure) + assert.Equal(t, "secret", installCmdOptions.registry.Secret) } func TestInstallRegistryWithAuthFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--registry-auth-password", "authPassword", "--registry-auth-server", "authServer", "--registry-auth-username", "authUsername") assert.Nil(t, err) - assert.Equal(t, "authPassword", runCmdOptions.registryAuth.Password) - assert.Equal(t, "authServer", runCmdOptions.registryAuth.Server) - assert.Equal(t, "authUsername", runCmdOptions.registryAuth.Username) + assert.Equal(t, "authPassword", installCmdOptions.registryAuth.Password) + assert.Equal(t, "authServer", installCmdOptions.registryAuth.Server) + assert.Equal(t, "authUsername", installCmdOptions.registryAuth.Username) } func TestInstallRuntimeVersionFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--runtime-version", "1.3.0") assert.Nil(t, err) - assert.Equal(t, "1.3.0", runCmdOptions.RuntimeVersion) + assert.Equal(t, "1.3.0", installCmdOptions.RuntimeVersion) } func TestInstallSaveFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--save") assert.Nil(t, err) - assert.Equal(t, true, runCmdOptions.Save) + assert.Equal(t, true, installCmdOptions.Save) } func TestInstallSkipClusterSetupFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--skip-cluster-setup") assert.Nil(t, err) - assert.Equal(t, true, runCmdOptions.SkipClusterSetup) + assert.Equal(t, true, installCmdOptions.SkipClusterSetup) } func TestInstallSkipOperatorSetupFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--skip-operator-setup") assert.Nil(t, err) - assert.Equal(t, true, runCmdOptions.SkipOperatorSetup) + assert.Equal(t, true, installCmdOptions.SkipOperatorSetup) } func TestInstallTraitProfileFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--trait-profile", "someString") assert.Nil(t, err) - assert.Equal(t, "someString", runCmdOptions.TraitProfile) + assert.Equal(t, "someString", installCmdOptions.TraitProfile) } func TestInstallWaitFlag(t *testing.T) { - runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t) + installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--wait") assert.Nil(t, err) - assert.Equal(t, true, runCmdOptions.Wait) + assert.Equal(t, true, installCmdOptions.Wait) } func TestDecodeMavenSettings(t *testing.T) {