-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat-iam-roles-anywhere-kafka
- Loading branch information
Showing
17 changed files
with
269 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
Copyright 2023 The Dapr Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package postgres | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestMetadata(t *testing.T) { | ||
t.Run("missing connection string", func(t *testing.T) { | ||
m := psqlMetadata{} | ||
props := map[string]string{} | ||
|
||
err := m.InitWithMetadata(props) | ||
require.Error(t, err) | ||
require.ErrorContains(t, err, "connection string") | ||
}) | ||
|
||
t.Run("has connection string", func(t *testing.T) { | ||
m := psqlMetadata{} | ||
props := map[string]string{ | ||
"connectionString": "foo", | ||
} | ||
|
||
err := m.InitWithMetadata(props) | ||
require.NoError(t, err) | ||
}) | ||
|
||
t.Run("default timeout", func(t *testing.T) { | ||
m := psqlMetadata{} | ||
props := map[string]string{ | ||
"connectionString": "foo", | ||
} | ||
|
||
err := m.InitWithMetadata(props) | ||
require.NoError(t, err) | ||
assert.Equal(t, 20*time.Second, m.Timeout) | ||
}) | ||
|
||
t.Run("invalid timeout", func(t *testing.T) { | ||
m := psqlMetadata{} | ||
props := map[string]string{ | ||
"connectionString": "foo", | ||
"timeout": "NaN", | ||
} | ||
|
||
err := m.InitWithMetadata(props) | ||
require.Error(t, err) | ||
}) | ||
|
||
t.Run("positive timeout", func(t *testing.T) { | ||
m := psqlMetadata{} | ||
props := map[string]string{ | ||
"connectionString": "foo", | ||
"timeout": "42", | ||
} | ||
|
||
err := m.InitWithMetadata(props) | ||
require.NoError(t, err) | ||
assert.Equal(t, 42*time.Second, m.Timeout) | ||
}) | ||
|
||
t.Run("zero timeout", func(t *testing.T) { | ||
m := psqlMetadata{} | ||
props := map[string]string{ | ||
"connectionString": "foo", | ||
"timeout": "0", | ||
} | ||
|
||
err := m.InitWithMetadata(props) | ||
require.Error(t, err) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.