mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.
## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
209 lines
4.3 KiB
Go
209 lines
4.3 KiB
Go
package config
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/gocql/gocql"
|
|
)
|
|
|
|
func TestCassandraStoreConsistency_GetConsistency(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
input *CassandraStoreConsistency
|
|
want gocql.Consistency
|
|
}{
|
|
{
|
|
name: "Nil Consistency Settings",
|
|
input: nil,
|
|
want: gocql.LocalQuorum,
|
|
},
|
|
{
|
|
name: "Empty Consistency Settings",
|
|
input: &CassandraStoreConsistency{},
|
|
want: gocql.LocalQuorum,
|
|
},
|
|
{
|
|
name: "Empty Default Settings",
|
|
input: &CassandraStoreConsistency{
|
|
Default: &CassandraConsistencySettings{},
|
|
},
|
|
want: gocql.LocalQuorum,
|
|
},
|
|
{
|
|
name: "Default Override",
|
|
input: &CassandraStoreConsistency{
|
|
Default: &CassandraConsistencySettings{
|
|
Consistency: "All",
|
|
},
|
|
},
|
|
want: gocql.All,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
c := tt.input
|
|
if got := c.GetConsistency(); !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("CassandraStoreConsistency.GetConsistency() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestCassandraStoreConsistency_GetSerialConsistency(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
input *CassandraStoreConsistency
|
|
want gocql.SerialConsistency
|
|
}{
|
|
{
|
|
name: "Nil Consistency Settings",
|
|
input: nil,
|
|
want: gocql.LocalSerial,
|
|
},
|
|
{
|
|
name: "Empty Consistency Settings",
|
|
input: &CassandraStoreConsistency{},
|
|
want: gocql.LocalSerial,
|
|
},
|
|
{
|
|
name: "Empty Default Settings",
|
|
input: &CassandraStoreConsistency{
|
|
Default: &CassandraConsistencySettings{},
|
|
},
|
|
want: gocql.LocalSerial,
|
|
},
|
|
{
|
|
name: "Default Override",
|
|
input: &CassandraStoreConsistency{
|
|
Default: &CassandraConsistencySettings{
|
|
SerialConsistency: "serial",
|
|
},
|
|
},
|
|
want: gocql.Serial,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
c := tt.input
|
|
if got := c.GetSerialConsistency(); !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("CassandraStoreConsistency.GetSerialConsistency() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestCassandraConsistencySettings_validate(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
settings *CassandraConsistencySettings
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "nil settings",
|
|
settings: nil,
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "empty fields",
|
|
settings: &CassandraConsistencySettings{
|
|
Consistency: "",
|
|
SerialConsistency: "",
|
|
},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "happy path",
|
|
settings: &CassandraConsistencySettings{
|
|
Consistency: "Local_Quorum",
|
|
SerialConsistency: "lOcal_sErial",
|
|
},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "bad consistency",
|
|
settings: &CassandraConsistencySettings{
|
|
Consistency: "bad_value",
|
|
SerialConsistency: "local_serial",
|
|
},
|
|
wantErr: true,
|
|
},
|
|
{
|
|
name: "bad serial consistency",
|
|
settings: &CassandraConsistencySettings{
|
|
Consistency: "local_quorum",
|
|
SerialConsistency: "bad_value",
|
|
},
|
|
wantErr: true,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
c := tt.settings
|
|
if err := c.validate(); (err != nil) != tt.wantErr {
|
|
t.Errorf("CassandraConsistencySettings.validate() error = %v, wantErr %v", err, tt.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestCassandraStoreConsistency_validate(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
settings *CassandraStoreConsistency
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "nil settings",
|
|
settings: nil,
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "empty settings",
|
|
settings: &CassandraStoreConsistency{},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "empty default settings",
|
|
settings: &CassandraStoreConsistency{
|
|
Default: &CassandraConsistencySettings{},
|
|
},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "good default settings",
|
|
settings: &CassandraStoreConsistency{
|
|
Default: &CassandraConsistencySettings{
|
|
Consistency: "one",
|
|
},
|
|
},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "bad default settings",
|
|
settings: &CassandraStoreConsistency{
|
|
Default: &CassandraConsistencySettings{
|
|
Consistency: "fake_value",
|
|
},
|
|
},
|
|
wantErr: true,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
c := tt.settings
|
|
if err := c.validate(); (err != nil) != tt.wantErr {
|
|
t.Errorf("CassandraStoreConsistency.validate() error = %v, wantErr %v", err, tt.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|