pominal/config_test.go

55 lines
1.6 KiB
Go
Raw Normal View History

/*
Pominal
Copyright (C) 2020 Daniel Anglin
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package main
import (
"reflect"
"testing"
)
// TestNewConfig validates the factory function for generating new
// PominalConfig values.
func TestNewPominalConfig(t *testing.T) {
t.Log("Given the need to test the creation of a new Config.")
{
for _, c := range configTestCases {
testFunc := func(t *testing.T) {
t.Log(c.description)
res, err := newPominalConfig(
c.file,
c.workTimeFlag,
c.shortBreakTimeFlag,
c.longBreakTimeFlag,
c.maxWorkSessionsFlag,
)
if err != nil {
t.Fatalf("%s\tError while creating the PominalConfig value, %s", failure, err.Error())
}
if !reflect.DeepEqual(res, c.expectedConfiguration) {
t.Errorf("%s\tUnexpected PominalConfig value created. Expected %v, received %v.", failure, c.expectedConfiguration, res)
} else {
t.Logf("%s\tTest passed.", success)
}
}
t.Run(c.name, testFunc)
}
}
}