diff --git a/.idea/workspace.xml b/.idea/workspace.xml index bccf6a0e3f4d308f023312647a6da8179e990180..6255d274610be75bd58b31b34742aea51ad7ef95 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -6,18 +6,9 @@ <component name="ChangeListManager"> <list default="true" id="9979eb22-471e-4f2f-b624-fd3edb5e8c6e" name="Changes" comment=""> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/database-1_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/database-1_test.go" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/database-2_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/database-2_test.go" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/database-3_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/database-3_test.go" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/database-4_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/database-4_test.go" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/database-5_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/database-5_test.go" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/database-7_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/database-7_test.go" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/database-8_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/database-8_test.go" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/database.go" beforeDir="false" afterPath="$PROJECT_DIR$/database.go" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/database_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/database_test.go" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/job-syncer.go" beforeDir="false" afterPath="$PROJECT_DIR$/job-syncer.go" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/job-syncer_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/job-syncer_test.go" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/nix/scripts/go-task.nix" beforeDir="false" afterPath="$PROJECT_DIR$/nix/scripts/go-task.nix" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/database-6_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/database-6_test.go" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/issue-1_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/issue-1_test.go" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/manager.go" beforeDir="false" afterPath="$PROJECT_DIR$/manager.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/nix/scripts/run-tests.nix" beforeDir="false" afterPath="$PROJECT_DIR$/nix/scripts/run-tests.nix" afterDir="false" /> </list> <option name="SHOW_DIALOG" value="false" /> @@ -58,11 +49,13 @@ "DefaultGoTemplateProperty": "Go File", "Go Test.TestDummyRunnable in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", "Go Test.TestResetStats in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestRoundTrip in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", "Go Test.TestScheduleJob in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", "Go Test.TestStructure in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", "Go Test.TestTimeFunctionSame in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", "Go Test.TestWriteToDB1 in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", "Go Test.TestWriteToDB2 in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", + "Go Test.TestWriteToDB4 in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", "Go Test.go test gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug", "RunOnceActivity.ShowReadmeOnStart": "true", "RunOnceActivity.go.formatter.settings.were.checked": "true", @@ -90,7 +83,7 @@ <recent name="$PROJECT_DIR$/.back" /> </key> </component> - <component name="RunManager" selected="Go Test.TestWriteToDB1 in gitlab.schukai.com/oss/libraries/go/services/job-queues"> + <component name="RunManager" selected="Go Test.TestRoundTrip in gitlab.schukai.com/oss/libraries/go/services/job-queues"> <configuration default="true" type="GoApplicationRunConfiguration" factoryName="Go Application"> <module name="job-queues" /> <working_directory value="$PROJECT_DIR$" /> @@ -111,7 +104,7 @@ <pattern value="^\QTestDummyRunnable\E$" /> <method v="2" /> </configuration> - <configuration name="TestResetStats in gitlab.schukai.com/oss/libraries/go/services/job-queues" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true"> + <configuration name="TestRoundTrip in gitlab.schukai.com/oss/libraries/go/services/job-queues" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true"> <module name="job-queues" /> <working_directory value="$PROJECT_DIR$" /> <kind value="PACKAGE" /> @@ -119,7 +112,7 @@ <directory value="$PROJECT_DIR$" /> <filePath value="$PROJECT_DIR$" /> <framework value="gotest" /> - <pattern value="^\QTestResetStats\E$" /> + <pattern value="^\QTestRoundTrip\E$" /> <method v="2" /> </configuration> <configuration name="TestWriteToDB1 in gitlab.schukai.com/oss/libraries/go/services/job-queues" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true"> @@ -144,21 +137,22 @@ <pattern value="^\QTestWriteToDB2\E$" /> <method v="2" /> </configuration> - <configuration default="true" type="GoTestRunConfiguration" factoryName="Go Test"> + <configuration name="TestWriteToDB4 in gitlab.schukai.com/oss/libraries/go/services/job-queues" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true"> <module name="job-queues" /> <working_directory value="$PROJECT_DIR$" /> - <go_parameters value="-i" /> - <kind /> + <kind value="PACKAGE" /> + <package value="gitlab.schukai.com/oss/libraries/go/services/job-queues" /> <directory value="$PROJECT_DIR$" /> <filePath value="$PROJECT_DIR$" /> <framework value="gotest" /> + <pattern value="^\QTestWriteToDB4\E$" /> <method v="2" /> </configuration> - <configuration name="go test gitlab.schukai.com/oss/libraries/go/services/job-queues" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true"> + <configuration default="true" type="GoTestRunConfiguration" factoryName="Go Test"> <module name="job-queues" /> <working_directory value="$PROJECT_DIR$" /> - <kind value="PACKAGE" /> - <package value="gitlab.schukai.com/oss/libraries/go/services/job-queues" /> + <go_parameters value="-i" /> + <kind /> <directory value="$PROJECT_DIR$" /> <filePath value="$PROJECT_DIR$" /> <framework value="gotest" /> @@ -166,11 +160,11 @@ </configuration> <recent_temporary> <list> + <item itemvalue="Go Test.TestRoundTrip in gitlab.schukai.com/oss/libraries/go/services/job-queues" /> + <item itemvalue="Go Test.TestWriteToDB4 in gitlab.schukai.com/oss/libraries/go/services/job-queues" /> <item itemvalue="Go Test.TestWriteToDB1 in gitlab.schukai.com/oss/libraries/go/services/job-queues" /> <item itemvalue="Go Test.TestWriteToDB2 in gitlab.schukai.com/oss/libraries/go/services/job-queues" /> <item itemvalue="Go Test.TestDummyRunnable in gitlab.schukai.com/oss/libraries/go/services/job-queues" /> - <item itemvalue="Go Test.go test gitlab.schukai.com/oss/libraries/go/services/job-queues" /> - <item itemvalue="Go Test.TestResetStats in gitlab.schukai.com/oss/libraries/go/services/job-queues" /> </list> </recent_temporary> </component> @@ -206,7 +200,7 @@ </line-breakpoint> <line-breakpoint enabled="true" type="DlvLineBreakpoint"> <url>file://$PROJECT_DIR$/database-2_test.go</url> - <line>25</line> + <line>32</line> <option name="timeStamp" value="20" /> </line-breakpoint> <line-breakpoint enabled="true" type="DlvLineBreakpoint"> @@ -214,6 +208,11 @@ <line>70</line> <option name="timeStamp" value="21" /> </line-breakpoint> + <line-breakpoint enabled="true" type="DlvLineBreakpoint"> + <url>file://$PROJECT_DIR$/job-syncer.go</url> + <line>62</line> + <option name="timeStamp" value="23" /> + </line-breakpoint> </breakpoints> </breakpoint-manager> </component> diff --git a/database-6_test.go b/database-6_test.go index 09c9a5ce410210d323985ad58e5be33bd2e47ec7..d73048a1332b3dccb716e9a7c49d5743410750df 100644 --- a/database-6_test.go +++ b/database-6_test.go @@ -18,7 +18,7 @@ func TestWriteToDB6(t *testing.T) { // it is necessary to have a running mysql server // docker rm -f mysql-test && \ // docker run --name mysql-test -e MYSQL_ROOT_PASSWORD=my-secret-pw -e MYSQL_DATABASE=testdb -p 3306:3306 -d mysql:latest && \ - // docker logs -f mysql-test + // docker logs -f mysql-test //dsn := "root:my-secret-pw@tcp(localhost:3306)/testdb?charset=utf8mb4&parseTime=True&loc=Local" //db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{}) diff --git a/issue-1_test.go b/issue-1_test.go index 1915a4cd2ec6d263e00fcae5161ffea13ade15ed..2b94af86f8b40cb3f67dd1163eb18dfa4b708ae9 100644 --- a/issue-1_test.go +++ b/issue-1_test.go @@ -16,7 +16,7 @@ import ( ) // TestRoundTrip tests the round trip of jobs from yaml to the manager and back to yaml -// This test runs forever and must be stopped manually +// This test runs forever and must be stopped manually. this test run without database // Use the following command to run this test: // go test -timeout 6h -run TestRoundTrip -v func TestRoundTrip(t *testing.T) { @@ -63,6 +63,8 @@ func TestRoundTrip(t *testing.T) { var err error + t.Log("This test runs forever and must be stopped manually") + cronInstance := cron.New(cron.WithSeconds()) cronInstance.Start() diff --git a/manager.go b/manager.go index 405d327b8dc7d1489a682ff2d9bd7a42f31a4ed4..657d3bd03997ac3abb171581bb5d2656ef55ad9d 100644 --- a/manager.go +++ b/manager.go @@ -467,7 +467,7 @@ func (m *Manager) Start() error { return ErrManagerAlreadyRunning } - if m.jobSyncer == nil { + if m.jobSyncer == nil && m.database != nil { m.jobSyncer = NewJobSyncer(m) } diff --git a/nix/scripts/go-task.nix b/nix/scripts/go-task.nix index 406aeacae8a4e6b19d2296bfe1b72d38b18a6c53..15c7eb25131660e419fab1a2509566337eda4d2e 100644 --- a/nix/scripts/go-task.nix +++ b/nix/scripts/go-task.nix @@ -13,7 +13,7 @@ - rt env: TEST_BY_TASK: true - USER_WORKING_DIR: "{{.USER_WORKING_DIR}}" + USER_WORKING_DIR: "{{.USER_WORKING_DIR}}" cmds: - run-tests silent: true diff --git a/nix/scripts/run-tests.nix b/nix/scripts/run-tests.nix index befcdfaa35c76772ceb25864068d6c30cce4a98d..bad5005a8b9264ac232cca1a66c0aa28db61535e 100644 --- a/nix/scripts/run-tests.nix +++ b/nix/scripts/run-tests.nix @@ -24,7 +24,7 @@ in if [[ "$selection" == "run all tests" ]]; then echo_ok "Running all tests" - if ! ${pkgs.go}/bin/go test -v -failfast ./... + if ! ${pkgs.go}/bin/go test -tags runOnTask -v -failfast ./... then echo_fail "ERROR: Tests failed, check your Go!" exit 1 @@ -52,8 +52,8 @@ in echo_ok "No tests selected, exiting." exit 0 fi - - if ! ${pkgs.go}/bin/go test -run "$(echo $selected_tests | tr '\n' "")" + + if ! ${pkgs.go}/bin/go test -tags runOnTask -run "$(echo $selected_tests)" then echo_fail "ERROR: Tests failed, check your Go!" exit 1