diff --git a/backend/internal/config/config_test.go b/backend/internal/config/config_test.go index cb02a31..e8ddce8 100644 --- a/backend/internal/config/config_test.go +++ b/backend/internal/config/config_test.go @@ -5,8 +5,12 @@ import ( "testing" ) +// TestNewConfig tests the creation of a new configuration object func TestNewConfig(t *testing.T) { + // Arrange c := NewConfig() + + // Act & Assert if c.Port != 8080 { t.Errorf("Expected port to be 8080, got %d", c.Port) } @@ -24,9 +28,15 @@ func TestNewConfig(t *testing.T) { } } +// TestWriteConfig tests the function to write the configuration to a file func TestWriteConfig(t *testing.T) { + // Arrange c := NewConfig() + + //Act err := c.WriteConfigToFile("test.toml") + + // Assert if err != nil { t.Errorf("Expected no error, got %s", err) } @@ -35,14 +45,23 @@ func TestWriteConfig(t *testing.T) { _ = os.Remove("test.toml") } +// TestReadConfig tests the function to read the configuration from a file func TestReadConfig(t *testing.T) { + // Arrange c := NewConfig() + + // Act err := c.WriteConfigToFile("test.toml") + + // Assert if err != nil { t.Errorf("Expected no error, got %s", err) } + // Act c2, err := ReadConfigFromFile("test.toml") + + // Assert if err != nil { t.Errorf("Expected no error, got %s", err) }