summaryrefslogtreecommitdiff
path: root/internal/router/session_test.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2022-05-30 13:41:24 +0100
committerLibravatar GitHub <noreply@github.com>2022-05-30 14:41:24 +0200
commit43ac0cdb9c4eea9d3c5eceb2c11b9e5b98b87b00 (patch)
treef0d5967d0ce639b6bc82aaf607f62e228fdf4559 /internal/router/session_test.go
parent[chore] Mastodon api fixups (#617) (diff)
downloadgotosocial-43ac0cdb9c4eea9d3c5eceb2c11b9e5b98b87b00.tar.xz
[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 <grufwub@gmail.com> * improved code comment Signed-off-by: kim <grufwub@gmail.com> * linter Signed-off-by: kim <grufwub@gmail.com> * fix unmarshaling Signed-off-by: kim <grufwub@gmail.com> * remove kim's custom go compiler changes Signed-off-by: kim <grufwub@gmail.com> * generate setter and flag-name functions, implement these in codebase Signed-off-by: kim <grufwub@gmail.com> * update deps Signed-off-by: kim <grufwub@gmail.com> * small change Signed-off-by: kim <grufwub@gmail.com> * appease the linter... Signed-off-by: kim <grufwub@gmail.com> * move configuration into ConfigState structure, ensure reloading to/from viper settings to keep in sync Signed-off-by: kim <grufwub@gmail.com> * lint Signed-off-by: kim <grufwub@gmail.com> * update code comments Signed-off-by: kim <grufwub@gmail.com> * fix merge issue Signed-off-by: kim <grufwub@gmail.com> * fix merge issue Signed-off-by: kim <grufwub@gmail.com> * improved version string (removes time + go version) Signed-off-by: kim <grufwub@gmail.com> * fix version string build to pass test script + consolidate logic in func Signed-off-by: kim <grufwub@gmail.com> * add license text, update config.Defaults comment Signed-off-by: kim <grufwub@gmail.com> * add license text to generated config helpers file Signed-off-by: kim <grufwub@gmail.com> * defer unlock on config.Set___(), to ensure unlocked on panic Signed-off-by: kim <grufwub@gmail.com> * make it more obvious which cmd flags are being attached Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/router/session_test.go')
-rw-r--r--internal/router/session_test.go27
1 files changed, 13 insertions, 14 deletions
diff --git a/internal/router/session_test.go b/internal/router/session_test.go
index d36da9596..5f4777a48 100644
--- a/internal/router/session_test.go
+++ b/internal/router/session_test.go
@@ -21,7 +21,6 @@ package router_test
import (
"testing"
- "github.com/spf13/viper"
"github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/router"
@@ -37,8 +36,8 @@ func (suite *SessionTestSuite) SetupTest() {
}
func (suite *SessionTestSuite) TestDeriveSessionNameLocalhostWithPort() {
- viper.Set(config.Keys.Protocol, "http")
- viper.Set(config.Keys.Host, "localhost:8080")
+ config.SetProtocol("http")
+ config.SetHost("localhost:8080")
sessionName, err := router.SessionName()
suite.NoError(err)
@@ -46,8 +45,8 @@ func (suite *SessionTestSuite) TestDeriveSessionNameLocalhostWithPort() {
}
func (suite *SessionTestSuite) TestDeriveSessionNameLocalhost() {
- viper.Set(config.Keys.Protocol, "http")
- viper.Set(config.Keys.Host, "localhost")
+ config.SetProtocol("http")
+ config.SetHost("localhost")
sessionName, err := router.SessionName()
suite.NoError(err)
@@ -55,8 +54,8 @@ func (suite *SessionTestSuite) TestDeriveSessionNameLocalhost() {
}
func (suite *SessionTestSuite) TestDeriveSessionNoProtocol() {
- viper.Set(config.Keys.Protocol, "")
- viper.Set(config.Keys.Host, "localhost")
+ config.SetProtocol("")
+ config.SetHost("localhost")
sessionName, err := router.SessionName()
suite.EqualError(err, "parse \"://localhost\": missing protocol scheme")
@@ -64,9 +63,9 @@ func (suite *SessionTestSuite) TestDeriveSessionNoProtocol() {
}
func (suite *SessionTestSuite) TestDeriveSessionNoHost() {
- viper.Set(config.Keys.Protocol, "https")
- viper.Set(config.Keys.Host, "")
- viper.Set(config.Keys.Port, 0)
+ config.SetProtocol("https")
+ config.SetHost("")
+ config.SetPort(0)
sessionName, err := router.SessionName()
suite.EqualError(err, "could not derive hostname without port from https://")
@@ -74,8 +73,8 @@ func (suite *SessionTestSuite) TestDeriveSessionNoHost() {
}
func (suite *SessionTestSuite) TestDeriveSessionOK() {
- viper.Set(config.Keys.Protocol, "https")
- viper.Set(config.Keys.Host, "example.org")
+ config.SetProtocol("https")
+ config.SetHost("example.org")
sessionName, err := router.SessionName()
suite.NoError(err)
@@ -83,8 +82,8 @@ func (suite *SessionTestSuite) TestDeriveSessionOK() {
}
func (suite *SessionTestSuite) TestDeriveSessionIDNOK() {
- viper.Set(config.Keys.Protocol, "https")
- viper.Set(config.Keys.Host, "fóid.org")
+ config.SetProtocol("https")
+ config.SetHost("fóid.org")
sessionName, err := router.SessionName()
suite.NoError(err)