commento/api/config_test.go
Adhityaa a090770b73 api: Add go files
I know this is a huge commit, but I can't be bothered to check
this in part by part.
2018-05-27 23:40:46 +05:30

34 lines
672 B
Go

package main
import (
"os"
"testing"
)
func TestParseConfigBasics(t *testing.T) {
os.Setenv("ORIGIN", "https://commento.io")
if err := parseConfig(); err != nil {
t.Errorf("unexpected error when parsing config: %v", err)
return
}
// This test feels kinda stupid, but whatever.
if os.Getenv("PORT") != "8080" {
t.Errorf("expected PORT=8080, but PORT=%s instead", os.Getenv("PORT"))
return
}
os.Setenv("PORT", "1886")
if err := parseConfig(); err != nil {
t.Errorf("unexpected error when parsing config: %v", err)
return
}
if os.Getenv("PORT") != "1886" {
t.Errorf("expected PORT=1886, but PORT=%s instead", os.Getenv("PORT"))
return
}
}