diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 094d16b..7a83a0d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,7 @@ name: CI on: + workflow_dispatch: pull_request: branches: [main] push: @@ -33,6 +34,16 @@ jobs: needs: check-changes if: ${{ needs.check-changes.outputs.go == 'true' }} runs-on: ubuntu-latest + services: + obs: + image: ghcr.io/andreykaipov/goobs:latest + ports: [4455:1234] + obs-record: + image: ghcr.io/andreykaipov/goobs:latest + ports: [4456:1234] + obs-stream: + image: ghcr.io/andreykaipov/goobs:latest + ports: [4457:1234] steps: - uses: actions/checkout@v4 - uses: magnetikonline/action-golang-cache@v5 diff --git a/go.mod b/go.mod index e5d5745..d71daca 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/andreykaipov/goobs -go 1.20 +go 1.23 require ( github.com/buger/jsonparser v1.1.1 diff --git a/internal/generate/tests/main.go b/internal/generate/tests/main.go index ac27a6f..bfe4d25 100644 --- a/internal/generate/tests/main.go +++ b/internal/generate/tests/main.go @@ -22,6 +22,8 @@ var ( // I am just too lazy to get them to not error. // requestsTestsAssertingErrors = []string{ + "config.CreateProfile", // docker profile already exists in image configs + "config.RemoveProfile", // can't remove the only profile "config.CreateSceneCollection", // we start with a `SceneCollectionName` collection already "filters.SetSourceFilterName", // not idempotent "general.CallVendorRequest", // no other third party plugins in my obs image @@ -121,6 +123,8 @@ func generateRequestTest(subclient, category string, structs map[string]StructFi case "*string": lit := "" switch field { + case "ProfileName": + lit = "docker" case "Realm": lit = "OBS_WEBSOCKET_DATA_REALM_GLOBAL" case "MediaAction": @@ -225,7 +229,7 @@ func generateRequestTest(subclient, category string, structs map[string]StructFi })), ), Qual(assert, "NoError").Call(Id("t"), Id("err")), - //Defer().Id("client").Dot("Disconnect").Call(), + // Defer().Id("client").Dot("Disconnect").Call(), Id("t").Dot("Cleanup").Call(Func().Call().Block( Id("client").Dot("Disconnect").Call(), diff --git a/script/test.sh b/script/test.sh index b024594..87c241f 100755 --- a/script/test.sh +++ b/script/test.sh @@ -1,8 +1,11 @@ #!/bin/sh -cleanup() { docker stop obs-record obs-stream; } +cleanup() { + if [ -n "$CI" ]; then return; fi + docker stop obs-record obs-stream +} -setup() { +setup_docker() { echo "Setting up OBS instances for functional tests..." obs="$(docker container inspect -f '{{.State.Status}}' obs || true)" @@ -20,7 +23,10 @@ setup() { echo "Spinning up OBS instances for 'record' and 'stream' tests" docker run --rm --detach --name obs-record -p 4456:1234 ghcr.io/andreykaipov/goobs:latest docker run --rm --detach --name obs-stream -p 4457:1234 ghcr.io/andreykaipov/goobs:latest +} +setup() { + if [ -z "$CI" ]; then setup_docker; fi covermode=count echo "mode: $covermode" >coverall.out } @@ -33,10 +39,10 @@ gotest() { } main() { + : "${CI=}" set -eu trap cleanup EXIT setup - sleep 10 export OBS_PORT # note: `scenes` and `transitions` must be ran after `ui` diff --git a/zz_generated._test.go b/zz_generated._test.go index 8755a88..aa26866 100644 --- a/zz_generated._test.go +++ b/zz_generated._test.go @@ -36,11 +36,11 @@ func Test_config(t *testing.T) { client.Disconnect() }) - _, err = client.Config.CreateProfile(&config.CreateProfileParams{ProfileName: &[]string{"test"}[0]}) + _, err = client.Config.CreateProfile(&config.CreateProfileParams{ProfileName: &[]string{"docker"}[0]}) if err != nil { t.Logf("%s", err) } - assert.NoError(t, err) + assert.Error(t, err) _, err = client.Config.CreateSceneCollection( &config.CreateSceneCollectionParams{SceneCollectionName: &[]string{"test"}[0]}, ) @@ -89,7 +89,7 @@ func Test_config(t *testing.T) { t.Logf("%s", err) } assert.NoError(t, err) - _, err = client.Config.SetCurrentProfile(&config.SetCurrentProfileParams{ProfileName: &[]string{"test"}[0]}) + _, err = client.Config.SetCurrentProfile(&config.SetCurrentProfileParams{ProfileName: &[]string{"docker"}[0]}) if err != nil { t.Logf("%s", err) } @@ -144,11 +144,11 @@ func Test_config(t *testing.T) { t.Logf("%s", err) } assert.NoError(t, err) - _, err = client.Config.RemoveProfile(&config.RemoveProfileParams{ProfileName: &[]string{"test"}[0]}) + _, err = client.Config.RemoveProfile(&config.RemoveProfileParams{ProfileName: &[]string{"docker"}[0]}) if err != nil { t.Logf("%s", err) } - assert.NoError(t, err) + assert.Error(t, err) } func Test_filters(t *testing.T) {