diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 3978496..3481d1a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -70,4 +70,4 @@ jobs: env: CLARIFY_USERNAME: ${{ secrets.CLARIFY_USERNAME }} CLARIFY_PASSWORD: ${{ secrets.CLARIFY_PASSWORD }} - CLARIFY_ENDPOINT: ${{ secrets.CLARIFY_ENDPOINT }} + CLARIFY_ENDPOINT: ${{ vars.CLARIFY_ENDPOINT }} diff --git a/automation/routines_test.go b/automation/routines_test.go index 7d22812..1e75d9a 100644 --- a/automation/routines_test.go +++ b/automation/routines_test.go @@ -87,66 +87,66 @@ func TestRoutinesSubRoutines(t *testing.T) { t.Run("wildcard", test(testCase{ patterns: []string{"*"}, expectLines: []string{ - `level=INFO msg=OK routine=folder1/folder1/routine1`, - `level=INFO msg=OK routine=folder1/folder1/routine2`, - `level=INFO msg=OK routine=folder1/folder2/routine1`, - `level=INFO msg=OK routine=folder1/folder2/routine2`, - `level=INFO msg=OK routine=folder2/folder1/routine1`, - `level=INFO msg=OK routine=folder2/folder1/routine2`, - `level=INFO msg=OK routine=routine1`, - `level=INFO msg=OK routine=routine2`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder1/routine1`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder1/routine2`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder2/routine1`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder2/routine2`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder2/folder1/routine1`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder2/folder1/routine2`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=routine1`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=routine2`, }, })) t.Run("wildcard", test(testCase{ patterns: []string{"*/*"}, expectLines: []string{ - `level=INFO msg=OK routine=folder1/folder1/routine1`, - `level=INFO msg=OK routine=folder1/folder1/routine2`, - `level=INFO msg=OK routine=folder1/folder2/routine1`, - `level=INFO msg=OK routine=folder1/folder2/routine2`, - `level=INFO msg=OK routine=folder2/folder1/routine1`, - `level=INFO msg=OK routine=folder2/folder1/routine2`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder1/routine1`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder1/routine2`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder2/routine1`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder2/routine2`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder2/folder1/routine1`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder2/folder1/routine2`, }, })) t.Run("folder1,folder2", test(testCase{ patterns: []string{"folder1", "folder2"}, expectLines: []string{ - `level=INFO msg=OK routine=folder1/folder1/routine1`, - `level=INFO msg=OK routine=folder1/folder1/routine2`, - `level=INFO msg=OK routine=folder1/folder2/routine1`, - `level=INFO msg=OK routine=folder1/folder2/routine2`, - `level=INFO msg=OK routine=folder2/folder1/routine1`, - `level=INFO msg=OK routine=folder2/folder1/routine2`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder1/routine1`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder1/routine2`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder2/routine1`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder2/routine2`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder2/folder1/routine1`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder2/folder1/routine2`, }, })) t.Run("folder1", test(testCase{ patterns: []string{"folder1"}, expectLines: []string{ - `level=INFO msg=OK routine=folder1/folder1/routine1`, - `level=INFO msg=OK routine=folder1/folder1/routine2`, - `level=INFO msg=OK routine=folder1/folder2/routine1`, - `level=INFO msg=OK routine=folder1/folder2/routine2`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder1/routine1`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder1/routine2`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder2/routine1`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder2/routine2`, }, })) t.Run("folder1 wildcard routine1", test(testCase{ patterns: []string{"folder1/*/routine1"}, expectLines: []string{ - `level=INFO msg=OK routine=folder1/folder1/routine1`, - `level=INFO msg=OK routine=folder1/folder2/routine1`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder1/routine1`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder2/routine1`, }, })) t.Run("wildcard routine2", test(testCase{ patterns: []string{"*/*/routine2"}, expectLines: []string{ - `level=INFO msg=OK routine=folder1/folder1/routine2`, - `level=INFO msg=OK routine=folder1/folder2/routine2`, - `level=INFO msg=OK routine=folder2/folder1/routine2`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder1/routine2`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder1/folder2/routine2`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=folder2/folder1/routine2`, }, })) t.Run("routine1", test(testCase{ patterns: []string{"routine1"}, expectLines: []string{ - `level=INFO msg=OK routine=routine1`, + `level=INFO msg=OK app=github.com/clarify/clarify-go routine=routine1`, }, })) } diff --git a/examples/devdata_cli/go.mod b/examples/devdata_cli/go.mod index f9a648f..51c22a5 100644 --- a/examples/devdata_cli/go.mod +++ b/examples/devdata_cli/go.mod @@ -1,19 +1,14 @@ module github.com/clarify/clarify-go/devdata_cli -go 1.23 +go 1.23.0 -toolchain go1.23.2 +toolchain go1.24.5 require ( - github.com/clarify/clarify-go v0.3.0 + github.com/clarify/clarify-go v0.4.0 github.com/peterbourgon/ff/v3 v3.4.0 ) -require ( - github.com/golang/protobuf v1.5.3 // indirect - golang.org/x/oauth2 v0.13.0 // indirect - google.golang.org/appengine v1.6.8 // indirect - google.golang.org/protobuf v1.33.0 // indirect -) +require golang.org/x/oauth2 v0.30.0 // indirect -replace github.com/clarify/clarify-go v0.3.0 => ../../ +replace github.com/clarify/clarify-go v0.4.0 => ../../ diff --git a/examples/devdata_cli/go.sum b/examples/devdata_cli/go.sum index b2b784c..9cb8973 100644 --- a/examples/devdata_cli/go.sum +++ b/examples/devdata_cli/go.sum @@ -1,42 +1,4 @@ -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/peterbourgon/ff/v3 v3.4.0 h1:QBvM/rizZM1cB0p0lGMdmR7HxZeI/ZrBWB4DqLkMUBc= github.com/peterbourgon/ff/v3 v3.4.0/go.mod h1:zjJVUhx+twciwfDl0zBcFzl4dW8axCRyXE/eKY9RztQ= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY= -golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= -google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI= +golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU= diff --git a/go.mod b/go.mod index 8c858a9..0999009 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,9 @@ module github.com/clarify/clarify-go -go 1.23 +go 1.23.0 -require golang.org/x/oauth2 v0.13.0 +toolchain go1.24.5 -require ( - github.com/golang/protobuf v1.5.3 // indirect - golang.org/x/text v0.13.0 - google.golang.org/appengine v1.6.8 // indirect - google.golang.org/protobuf v1.33.0 // indirect -) +require golang.org/x/oauth2 v0.30.0 + +require golang.org/x/text v0.27.0 diff --git a/go.sum b/go.sum index 3cb2eb7..2401309 100644 --- a/go.sum +++ b/go.sum @@ -1,42 +1,4 @@ -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY= -golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= -google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI= +golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU= +golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= +golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= diff --git a/jsonrpc/error.go b/jsonrpc/error.go index c4ee5ae..ff69530 100644 --- a/jsonrpc/error.go +++ b/jsonrpc/error.go @@ -96,6 +96,7 @@ type ErrorData struct { Params map[string][]string `json:"params,omitempty"` InvalidResources []InvalidResource `json:"invalidResources,omitempty"` PartialResult json.RawMessage `json:"partialResult,omitempty"` + PathErrors json.RawMessage `json:"pathErrors,omitempty"` } // InvalidResource describes an invalid resource. diff --git a/test/common.go b/test/common.go index 9d5a483..a2dbae2 100644 --- a/test/common.go +++ b/test/common.go @@ -17,6 +17,7 @@ package test import ( "context" "encoding/json" + "fmt" "os" "runtime" "strings" @@ -33,13 +34,15 @@ const ( AnnotationValue = "in-the-banana-stand" ) -func getDefaultTimeRange() (time.Time, time.Time) { - tidenesMorgen := time.Unix(0, 0).UTC().Truncate(time.Hour) - tidenesKveld := tidenesMorgen.Add(10 * time.Hour) +// timeRange returns a default time range used for test queries. +func timeRange() (time.Time, time.Time) { + start := time.Unix(0, 0).UTC().Truncate(time.Hour) + end := start.Add(10 * time.Hour) - return tidenesMorgen, tidenesKveld + return start, end } +// TestName returns the name of the calling test function. func testName() string { pc := make([]uintptr, 10) n := runtime.Callers(3, pc) @@ -50,13 +53,17 @@ func testName() string { return funk } -func createPrefix() string { +// prefixFromTestName creates a prefix based on the test name. +func prefixFromTestName() string { test := testName() return test + "/" } -func getCredentials(t *testing.T) *clarify.Credentials { +// credentialsFromEnv reads Clarify credentials from environment variables. +func credentialsFromEnv(t *testing.T) *clarify.Credentials { + t.Helper() + var creds *clarify.Credentials username := os.Getenv("CLARIFY_USERNAME") @@ -88,23 +95,25 @@ func getCredentials(t *testing.T) *clarify.Credentials { return creds } -func jsonEncode[v any](t *testing.T, a v) { +// mustPrintJSON pretty-prints a value to stdout for test diagnostics. +func mustPrintJSON[v any](t *testing.T, a v) { + t.Helper() enc := json.NewEncoder(os.Stdout) - enc.SetIndent("", " ") - - err := enc.Encode(a) - if err != nil { - t.Errorf("%v", err) + if err := enc.Encode(a); err != nil { + t.Errorf("json encoding failed: %v", err) } } -func createAnnotationQuery(prefix string) fields.ResourceQuery { +// annotationQuery builds a filter for test resources based on a known annotation. +func annotationQuery(prefix string) fields.ResourceQuery { return fields.Query(). Where(fields.Comparisons{"annotations." + prefix + AnnotationKey: fields.Equal(AnnotationValue)}). Limit(10) } +// onlyError wraps a function that returns a result and error, +// and discards the result. func onlyError[R any](f func(TestArgs) (R, error)) func(TestArgs) error { return func(a TestArgs) error { _, err := f(a) @@ -113,14 +122,16 @@ func onlyError[R any](f func(TestArgs) (R, error)) func(TestArgs) error { } } -func applyTestArgs(a TestArgs, fs ...func(a TestArgs) error) { - for _, f := range fs { +// mustApplyTestArgs applies a series of test functions, panicking on error. +func mustApplyTestArgs(a TestArgs, fs ...func(a TestArgs) error) { + for i, f := range fs { if err := f(a); err != nil { - panic(err) + panic(fmt.Errorf("applyTestArgs fs[%d]: %w", i, err)) } } } +// TestArgs bundles common arguments for test operations. type TestArgs struct { ctx context.Context integration string @@ -128,6 +139,7 @@ type TestArgs struct { prefix string } +// Map transforms a slice using the provided function. func Map[A any, B any](f func(a A) B, as []A) []B { g := func(index int, a A) B { return f(a) @@ -136,6 +148,7 @@ func Map[A any, B any](f func(a A) B, as []A) []B { return MapIndex(g, as) } +// MapIndex transforms a slice using the provided index-aware function. func MapIndex[A any, B any](f func(i int, a A) B, as []A) []B { bs := make([]B, len(as)) diff --git a/test/data_frame_integration_test.go b/test/data_frame_integration_test.go index 7de5c8a..7d1bef5 100644 --- a/test/data_frame_integration_test.go +++ b/test/data_frame_integration_test.go @@ -15,20 +15,34 @@ package test import ( + "bytes" "context" + "encoding/json" + "log/slog" "testing" "time" clarify "github.com/clarify/clarify-go" "github.com/clarify/clarify-go/fields" + "github.com/clarify/clarify-go/jsonrpc" ) func TestDataFrame(t *testing.T) { ctx := context.Background() - creds := getCredentials(t) - client := creds.Client(ctx) - prefix := createPrefix() + creds := credentialsFromEnv(t) + h, err := creds.HTTPHandler(ctx) + if err != nil { + t.Fatal(err) + } + h.RequestLogger = func(request jsonrpc.Request, trace string, latency time.Duration, err error) { + var b bytes.Buffer + enc := json.NewEncoder(&b) + _ = enc.Encode(request) + slog.Debug("Performing JSON RPC request", "trace", trace, "latency", latency, "err", err, "body", json.RawMessage(b.Bytes())) + } + client := clarify.NewClient(creds.Integration, h) + prefix := prefixFromTestName() a := TestArgs{ ctx: ctx, integration: creds.Integration, @@ -36,9 +50,9 @@ func TestDataFrame(t *testing.T) { prefix: prefix, } - applyTestArgs(a, onlyError(insertDefault), onlyError(saveSignalsDefault), onlyError(publishSignalsDefault)) + mustApplyTestArgs(a, onlyError(insertDefault), onlyError(saveSignalsDefault), onlyError(publishSignalsDefault)) - t0, t1 := getDefaultTimeRange() + t0, t1 := timeRange() type testCase struct { testArgs TestArgs @@ -58,13 +72,13 @@ func TestDataFrame(t *testing.T) { t.Errorf("unexpected field found!") } - jsonEncode(t, result) + mustPrintJSON(t, result) } } t.Run("basic data frame test", test(testCase{ testArgs: a, - items: createAnnotationQuery(a.prefix), + items: annotationQuery(a.prefix), data: fields.Data().Where(fields.TimeRange(t0, t1)).RollupDuration(time.Hour, time.Monday), expectedFields: func(dfr *clarify.DataFrameResult) bool { return true @@ -73,7 +87,7 @@ func TestDataFrame(t *testing.T) { t.Run("less basic data frame test", test(testCase{ testArgs: a, - items: createAnnotationQuery(a.prefix), + items: annotationQuery(a.prefix), data: fields.Data().Where(fields.TimeRange(t1, t0)).RollupDuration(time.Hour, time.Monday), expectedFields: func(dfr *clarify.DataFrameResult) bool { return true @@ -86,14 +100,3 @@ func dataFrame(ctx context.Context, client *clarify.Client, items fields.Resourc return result, err } - -//lint:ignore U1000 Ignore unused function temporarily for debugging -func dataFrameDefault(a TestArgs) (*clarify.DataFrameResult, error) { - items := createAnnotationQuery(a.prefix) - t0, t1 := getDefaultTimeRange() - data := fields.Data(). - Where(fields.TimeRange(t0, t1)). - RollupDuration(time.Hour, time.Monday) - - return dataFrame(a.ctx, a.client, items, data) -} diff --git a/test/evaluate_integration_test.go b/test/evaluate_integration_test.go index 712f622..7be6d43 100644 --- a/test/evaluate_integration_test.go +++ b/test/evaluate_integration_test.go @@ -28,9 +28,9 @@ import ( func TestEvaluate(t *testing.T) { ctx := context.Background() - creds := getCredentials(t) + creds := credentialsFromEnv(t) client := creds.Client(ctx) - prefix := createPrefix() + prefix := prefixFromTestName() a := TestArgs{ ctx: ctx, integration: creds.Integration, @@ -38,9 +38,9 @@ func TestEvaluate(t *testing.T) { prefix: prefix, } - applyTestArgs(a, onlyError(insertDefault), onlyError(saveSignalsDefault), onlyError(publishSignalsDefault)) + mustApplyTestArgs(a, onlyError(insertDefault), onlyError(saveSignalsDefault), onlyError(publishSignalsDefault)) - t0, t1 := getDefaultTimeRange() + t0, t1 := timeRange() ir, err := selectItemsDefault(a) if err != nil { t.Errorf("%v", err) @@ -69,7 +69,7 @@ func TestEvaluate(t *testing.T) { t.Errorf("unexpected field found!") } - jsonEncode(t, result) + mustPrintJSON(t, result) } } @@ -90,7 +90,7 @@ func TestEvaluate(t *testing.T) { t.Run("basic evaluate test", test(testCase{ testArgs: a, itemIDs: itemIDs, - query: createAnnotationQuery(a.prefix), + query: annotationQuery(a.prefix), data: fields.Data().Where(fields.TimeRange(t0, t1)).RollupDuration(time.Hour, time.Monday), timeAggregation: fields.TimeAggregationAvg, groupAggregation: fields.GroupAggregationAvg, @@ -111,7 +111,7 @@ func TestEvaluate(t *testing.T) { t.Run("time aggregation test type "+fmt.Sprint(tagg), test(testCase{ testArgs: a, itemIDs: itemIDs, - query: createAnnotationQuery(a.prefix), + query: annotationQuery(a.prefix), data: fields.Data().Where(fields.TimeRange(t0, t1)).RollupDuration(time.Hour, time.Monday), timeAggregation: tagg, groupAggregation: fields.GroupAggregationAvg, @@ -130,7 +130,7 @@ func TestEvaluate(t *testing.T) { t.Run("group aggregation test type "+fmt.Sprint(gagg), test(testCase{ testArgs: a, itemIDs: itemIDs, - query: createAnnotationQuery(a.prefix), + query: annotationQuery(a.prefix), data: fields.Data().Where(fields.TimeRange(t0, t1)).RollupDuration(time.Hour, time.Monday), timeAggregation: fields.TimeAggregationAvg, groupAggregation: gagg, diff --git a/test/insert_integration_test.go b/test/insert_integration_test.go index 88eb043..e75a7d2 100644 --- a/test/insert_integration_test.go +++ b/test/insert_integration_test.go @@ -28,9 +28,9 @@ import ( func TestInsert(t *testing.T) { ctx := context.Background() - creds := getCredentials(t) + creds := credentialsFromEnv(t) client := creds.Client(ctx) - prefix := createPrefix() + prefix := prefixFromTestName() a := TestArgs{ ctx: ctx, integration: creds.Integration, @@ -54,7 +54,7 @@ func TestInsert(t *testing.T) { t.Errorf("unexpected field found!") } - jsonEncode(t, result) + mustPrintJSON(t, result) } } @@ -67,7 +67,7 @@ func TestInsert(t *testing.T) { } func insert(ctx context.Context, client *clarify.Client, prefix string) (*clarify.InsertResult, error) { - tt0, tt1 := getDefaultTimeRange() + tt0, tt1 := timeRange() t0 := fields.AsTimestamp(tt0) segmentSize := 15 * time.Minute segments := int(tt1.Sub(tt0)) / int(segmentSize) diff --git a/test/publish_signals_integration_test.go b/test/publish_signals_integration_test.go index 30b433d..574905a 100644 --- a/test/publish_signals_integration_test.go +++ b/test/publish_signals_integration_test.go @@ -30,9 +30,9 @@ import ( func TestPublishSignals(t *testing.T) { ctx := context.Background() - creds := getCredentials(t) + creds := credentialsFromEnv(t) client := creds.Client(ctx) - prefix := createPrefix() + prefix := prefixFromTestName() a := TestArgs{ ctx: ctx, @@ -41,7 +41,7 @@ func TestPublishSignals(t *testing.T) { prefix: prefix, } - applyTestArgs(a, onlyError(insertDefault), onlyError(saveSignalsDefault)) + mustApplyTestArgs(a, onlyError(insertDefault), onlyError(saveSignalsDefault)) type testCase struct { testArgs TestArgs diff --git a/test/save_signals_integration_test.go b/test/save_signals_integration_test.go index 9f53793..5497d23 100644 --- a/test/save_signals_integration_test.go +++ b/test/save_signals_integration_test.go @@ -28,9 +28,9 @@ import ( func TestSaveSignals(t *testing.T) { ctx := context.Background() - creds := getCredentials(t) + creds := credentialsFromEnv(t) client := creds.Client(ctx) - prefix := createPrefix() + prefix := prefixFromTestName() a := TestArgs{ ctx: ctx, @@ -39,7 +39,7 @@ func TestSaveSignals(t *testing.T) { prefix: prefix, } - applyTestArgs(a, onlyError(insertDefault)) + mustApplyTestArgs(a, onlyError(insertDefault)) type testCase struct { testArgs TestArgs @@ -57,7 +57,7 @@ func TestSaveSignals(t *testing.T) { t.Errorf("unexpected field found!") } - jsonEncode(t, result) + mustPrintJSON(t, result) } } diff --git a/test/select_items_integration_test.go b/test/select_items_integration_test.go index 375321f..ea93078 100644 --- a/test/select_items_integration_test.go +++ b/test/select_items_integration_test.go @@ -25,9 +25,9 @@ import ( func TestSelectItems(t *testing.T) { ctx := context.Background() - creds := getCredentials(t) + creds := credentialsFromEnv(t) client := creds.Client(ctx) - prefix := createPrefix() + prefix := prefixFromTestName() a := TestArgs{ ctx: ctx, @@ -36,7 +36,7 @@ func TestSelectItems(t *testing.T) { prefix: prefix, } - applyTestArgs(a, onlyError(insertDefault), onlyError(saveSignalsDefault), onlyError(publishSignalsDefault)) + mustApplyTestArgs(a, onlyError(insertDefault), onlyError(saveSignalsDefault), onlyError(publishSignalsDefault)) type testCase struct { testArgs TestArgs @@ -55,13 +55,13 @@ func TestSelectItems(t *testing.T) { t.Errorf("unexpected field found!") } - jsonEncode(t, result) + mustPrintJSON(t, result) } } t.Run("basic select items test", test(testCase{ testArgs: a, - items: createAnnotationQuery(a.prefix), + items: annotationQuery(a.prefix), expectedFields: func(sir *clarify.SelectItemsResult) bool { return true }, @@ -75,7 +75,7 @@ func selectItems(ctx context.Context, client *clarify.Client, items fields.Resou } func selectItemsDefault(a TestArgs) (*clarify.SelectItemsResult, error) { - items := createAnnotationQuery(a.prefix) + items := annotationQuery(a.prefix) return selectItems(a.ctx, a.client, items) } diff --git a/test/select_signals_integration_test.go b/test/select_signals_integration_test.go index c3b32d0..49e4350 100644 --- a/test/select_signals_integration_test.go +++ b/test/select_signals_integration_test.go @@ -25,9 +25,9 @@ import ( func TestSelectSignal(t *testing.T) { ctx := context.Background() - creds := getCredentials(t) + creds := credentialsFromEnv(t) client := creds.Client(ctx) - prefix := createPrefix() + prefix := prefixFromTestName() a := TestArgs{ ctx: ctx, integration: creds.Integration, @@ -35,7 +35,7 @@ func TestSelectSignal(t *testing.T) { prefix: prefix, } - applyTestArgs(a, onlyError(insertDefault), onlyError(saveSignalsDefault)) + mustApplyTestArgs(a, onlyError(insertDefault), onlyError(saveSignalsDefault)) type testCase struct { testArgs TestArgs @@ -54,13 +54,13 @@ func TestSelectSignal(t *testing.T) { t.Errorf("unexpected field found!") } - jsonEncode(t, result) + mustPrintJSON(t, result) } } t.Run("basic select signals test", test(testCase{ testArgs: a, - signals: createAnnotationQuery(a.prefix), + signals: annotationQuery(a.prefix), expectedFields: func(ssr *clarify.SelectSignalsResult) bool { return true },