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`.
119 lines
2.8 KiB
Go
119 lines
2.8 KiB
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/stretchr/testify/suite"
|
|
"go.temporal.io/server/tests/testutils"
|
|
)
|
|
|
|
const fileMode = os.FileMode(0644)
|
|
|
|
type (
|
|
LoaderSuite struct {
|
|
*require.Assertions
|
|
suite.Suite
|
|
}
|
|
|
|
itemsConfig struct {
|
|
Item1 string `yaml:"item1"`
|
|
Item2 string `yaml:"item2"`
|
|
}
|
|
|
|
testConfig struct {
|
|
Items itemsConfig `yaml:"items"`
|
|
}
|
|
)
|
|
|
|
func TestLoaderSuite(t *testing.T) {
|
|
suite.Run(t, new(LoaderSuite))
|
|
}
|
|
|
|
func (s *LoaderSuite) SetupTest() {
|
|
s.Assertions = require.New(s.T())
|
|
}
|
|
|
|
func (s *LoaderSuite) TestBaseYaml() {
|
|
dir := testutils.MkdirTemp(s.T(), "", "loader.testBaseYaml")
|
|
|
|
data := buildConfig(false, "", "")
|
|
err := os.WriteFile(path(dir, "base.yaml"), []byte(data), fileMode)
|
|
s.Nil(err)
|
|
|
|
envs := []string{"", "prod"}
|
|
zones := []string{"", "us-east-1a"}
|
|
|
|
for _, env := range envs {
|
|
for _, zone := range zones {
|
|
var cfg testConfig
|
|
err = Load(env, dir, zone, &cfg)
|
|
s.Nil(err)
|
|
s.Equal("hello__", cfg.Items.Item1)
|
|
s.Equal("world__", cfg.Items.Item2)
|
|
}
|
|
}
|
|
}
|
|
|
|
func (s *LoaderSuite) TestHierarchy() {
|
|
dir := testutils.MkdirTemp(s.T(), "", "loader.testHierarchy")
|
|
|
|
s.createFile(dir, "base.yaml", false, "", "")
|
|
s.createFile(dir, "development.yaml", false, "development", "")
|
|
s.createFile(dir, "prod.yaml", true, "prod", "")
|
|
s.createFile(dir, "prod_dca.yaml", true, "prod", "dca")
|
|
|
|
testCases := []struct {
|
|
env string
|
|
zone string
|
|
item1 string
|
|
item2 string
|
|
}{
|
|
{"", "", "hello_development_", "world_development_"},
|
|
{"", "dca", "hello_development_", "world_development_"},
|
|
{"", "pdx", "hello_development_", "world_development_"},
|
|
{"development", "", "hello_development_", "world_development_"},
|
|
{"development", "dca", "hello_development_", "world_development_"},
|
|
{"development", "pdx", "hello_development_", "world_development_"},
|
|
{"prod", "", "HELLO_PROD_", "world_prod_"},
|
|
{"prod", "dca", "HELLO_PROD_DCA", "world_prod_dca"},
|
|
{"prod", "pdx", "HELLO_PROD_", "world_prod_"},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
var cfg testConfig
|
|
err := Load(tc.env, dir, tc.zone, &cfg)
|
|
s.Nil(err)
|
|
s.Equal(tc.item1, cfg.Items.Item1)
|
|
s.Equal(tc.item2, cfg.Items.Item2)
|
|
}
|
|
}
|
|
|
|
func (s *LoaderSuite) TestInvalidPath() {
|
|
var cfg testConfig
|
|
err := Load("prod", "", "", &cfg)
|
|
s.NotNil(err)
|
|
}
|
|
|
|
func (s *LoaderSuite) createFile(dir string, file string, template bool, env string, zone string) {
|
|
err := os.WriteFile(path(dir, file), []byte(buildConfig(template, env, zone)), fileMode)
|
|
s.Nil(err)
|
|
}
|
|
|
|
func buildConfig(template bool, env, zone string) string {
|
|
comment := ""
|
|
if template {
|
|
comment = "# enable-template\n"
|
|
}
|
|
item1 := concat("hello", concat(env, zone))
|
|
if template {
|
|
item1 = `{{ "` + item1 + `" | upper }}`
|
|
}
|
|
item2 := concat("world", concat(env, zone))
|
|
return comment + `
|
|
items:
|
|
item1: ` + item1 + `
|
|
item2: ` + item2
|
|
}
|