From 43ac0cdb9c4eea9d3c5eceb2c11b9e5b98b87b00 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Mon, 30 May 2022 13:41:24 +0100 Subject: [chore] Global server configuration overhaul (#575) * move config flag names and usage to config package, rewrite config package to use global Configuration{} struct Signed-off-by: kim * improved code comment Signed-off-by: kim * linter Signed-off-by: kim * fix unmarshaling Signed-off-by: kim * remove kim's custom go compiler changes Signed-off-by: kim * generate setter and flag-name functions, implement these in codebase Signed-off-by: kim * update deps Signed-off-by: kim * small change Signed-off-by: kim * appease the linter... Signed-off-by: kim * move configuration into ConfigState structure, ensure reloading to/from viper settings to keep in sync Signed-off-by: kim * lint Signed-off-by: kim * update code comments Signed-off-by: kim * fix merge issue Signed-off-by: kim * fix merge issue Signed-off-by: kim * improved version string (removes time + go version) Signed-off-by: kim * fix version string build to pass test script + consolidate logic in func Signed-off-by: kim * add license text, update config.Defaults comment Signed-off-by: kim * add license text to generated config helpers file Signed-off-by: kim * defer unlock on config.Set___(), to ensure unlocked on panic Signed-off-by: kim * make it more obvious which cmd flags are being attached Signed-off-by: kim --- internal/api/s2s/webfinger/webfingerget_test.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'internal/api/s2s/webfinger/webfingerget_test.go') diff --git a/internal/api/s2s/webfinger/webfingerget_test.go b/internal/api/s2s/webfinger/webfingerget_test.go index 7871b6a3f..781fad027 100644 --- a/internal/api/s2s/webfinger/webfingerget_test.go +++ b/internal/api/s2s/webfinger/webfingerget_test.go @@ -27,7 +27,6 @@ import ( "testing" "github.com/gin-gonic/gin" - "github.com/spf13/viper" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" "github.com/superseriousbusiness/gotosocial/internal/api/s2s/webfinger" @@ -46,7 +45,7 @@ func (suite *WebfingerGetTestSuite) TestFingerUser() { targetAccount := suite.testAccounts["local_account_1"] // setup request - host := viper.GetString(config.Keys.Host) + host := config.GetHost() requestPath := fmt.Sprintf("/%s?resource=acct:%s@%s", webfinger.WebfingerBasePath, targetAccount.Username, host) recorder := httptest.NewRecorder() @@ -69,8 +68,9 @@ func (suite *WebfingerGetTestSuite) TestFingerUser() { } func (suite *WebfingerGetTestSuite) TestFingerUserWithDifferentAccountDomainByHost() { - viper.Set(config.Keys.Host, "gts.example.org") - viper.Set(config.Keys.AccountDomain, "example.org") + config.SetHost("gts.example.org") + config.SetAccountDomain("example.org") + clientWorker := concurrency.NewWorkerPool[messages.FromClientAPI](-1, -1) fedWorker := concurrency.NewWorkerPool[messages.FromFederator](-1, -1) suite.processor = processing.NewProcessor(suite.tc, suite.federator, testrig.NewTestOauthServer(suite.db), testrig.NewTestMediaManager(suite.db, suite.storage), suite.storage, suite.db, suite.emailSender, clientWorker, fedWorker) @@ -82,7 +82,7 @@ func (suite *WebfingerGetTestSuite) TestFingerUserWithDifferentAccountDomainByHo } // setup request - host := viper.GetString(config.Keys.Host) + host := config.GetHost() requestPath := fmt.Sprintf("/%s?resource=acct:%s@%s", webfinger.WebfingerBasePath, targetAccount.Username, host) recorder := httptest.NewRecorder() @@ -105,8 +105,9 @@ func (suite *WebfingerGetTestSuite) TestFingerUserWithDifferentAccountDomainByHo } func (suite *WebfingerGetTestSuite) TestFingerUserWithDifferentAccountDomainByAccountDomain() { - viper.Set(config.Keys.Host, "gts.example.org") - viper.Set(config.Keys.AccountDomain, "example.org") + config.SetHost("gts.example.org") + config.SetAccountDomain("example.org") + clientWorker := concurrency.NewWorkerPool[messages.FromClientAPI](-1, -1) fedWorker := concurrency.NewWorkerPool[messages.FromFederator](-1, -1) suite.processor = processing.NewProcessor(suite.tc, suite.federator, testrig.NewTestOauthServer(suite.db), testrig.NewTestMediaManager(suite.db, suite.storage), suite.storage, suite.db, suite.emailSender, clientWorker, fedWorker) @@ -118,7 +119,7 @@ func (suite *WebfingerGetTestSuite) TestFingerUserWithDifferentAccountDomainByAc } // setup request - accountDomain := viper.GetString(config.Keys.AccountDomain) + accountDomain := config.GetAccountDomain() requestPath := fmt.Sprintf("/%s?resource=acct:%s@%s", webfinger.WebfingerBasePath, targetAccount.Username, accountDomain) recorder := httptest.NewRecorder() @@ -144,7 +145,7 @@ func (suite *WebfingerGetTestSuite) TestFingerUserWithoutAcct() { targetAccount := suite.testAccounts["local_account_1"] // setup request -- leave out the 'acct:' prefix, which is prettymuch what pixelfed currently does - host := viper.GetString(config.Keys.Host) + host := config.GetHost() requestPath := fmt.Sprintf("/%s?resource=%s@%s", webfinger.WebfingerBasePath, targetAccount.Username, host) recorder := httptest.NewRecorder() -- cgit v1.2.3