Skip to content

Commit

Permalink
Reorganized tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiang committed Sep 16, 2024
1 parent 48fbc38 commit 277fde5
Show file tree
Hide file tree
Showing 15 changed files with 136 additions and 38 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ jobs:
with:
go-version: '1.20'

- name: Test Package
run: go test -v "./go-zabbix/.."

- name: Test Types Package
run: go test -v "./types/..."
- name: Test
run: go test -v -short "./..."

integration:
timeout-minutes: 31
Expand Down Expand Up @@ -90,7 +87,7 @@ jobs:
run: docker compose -f "docker-compose.yml" logs server

- name: Test
run: go test -v "./test/integration/..."
run: go test -v -run Integration "./..."

- name: Stop containers
if: always()
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
tests: unittests integration

unittests:
go test -v "./go-zabbix/.."
go test -v "./types/..."
go test -v -short "./..."

integration:
go test -v "./test/integration/..."
go test -v -run Integration "./..."
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ func main() {
Running the unit tests:

```bash
go test -v "./go-zabbix/.."
go test -v "./types/..."
go test -v -short "./..."
# or:
make unittests
```
Expand All @@ -124,7 +123,7 @@ export ZBX_VERSION=6.4
docker compose up -d
# server should be running in a minute
# run tests:
go test -v "./test/integration/..."
go test -v -run Integration "./..."
# or:
make integration
```
Expand Down
6 changes: 5 additions & 1 deletion test/integration/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
"github.com/fabiang/go-zabbix/test"
)

func TestActions(t *testing.T) {
func TestActionsIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

session := test.GetTestSession(t)

params := zabbix.ActionGetParams{}
Expand Down
6 changes: 5 additions & 1 deletion test/integration/alert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
"github.com/fabiang/go-zabbix/test"
)

func TestAlerts(t *testing.T) {
func TestAlertsIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

session := test.GetTestSession(t)

params := zabbix.AlertGetParams{
Expand Down
6 changes: 5 additions & 1 deletion test/integration/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
"github.com/fabiang/go-zabbix/test"
)

func TestEvents(t *testing.T) {
func TestEventsIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

session := test.GetTestSession(t)

params := zabbix.EventGetParams{
Expand Down
6 changes: 5 additions & 1 deletion test/integration/history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
"github.com/fabiang/go-zabbix/test"
)

func TestHistories(t *testing.T) {
func TestHistoriesIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

session := test.GetTestSession(t)

params := zabbix.HistoryGetParams{}
Expand Down
6 changes: 5 additions & 1 deletion test/integration/host_interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
"github.com/fabiang/go-zabbix/test"
)

func TestHostInterfaces(t *testing.T) {
func TestHostInterfacesIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

session := test.GetTestSession(t)

params := zabbix.HostInterfaceGetParams{}
Expand Down
6 changes: 5 additions & 1 deletion test/integration/hostgroups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
"github.com/fabiang/go-zabbix/test"
)

func TestHostgroups(t *testing.T) {
func TestHostgroupsIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

session := test.GetTestSession(t)

params := zabbix.HostgroupGetParams{}
Expand Down
89 changes: 74 additions & 15 deletions test/integration/hosts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,47 @@ func testHost(t *testing.T, params zabbix.HostGetParams) {
t.Logf("Validated %d Hosts", len(hosts))
}

func TestHostsTemplates(t *testing.T) {
func TestHostsTemplatesIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
IncludeTemplates: true,
}

testHost(t, params)
}

func TestHostsGroups(t *testing.T) {
func TestHostsGroupsIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectGroups: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsApplications(t *testing.T) {
func TestHostsApplicationsIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectApplications: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsDiscoveries(t *testing.T) {
func TestHostsDiscoveriesIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectDiscoveries: zabbix.SelectExtendedOutput,
}
Expand All @@ -63,7 +79,10 @@ func TestHostsDiscoveries(t *testing.T) {

}

func TestHostsDiscoveryRule(t *testing.T) {
func TestHostsDiscoveryRuleIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectDiscoveryRule: zabbix.SelectExtendedOutput,
Expand All @@ -72,79 +91,119 @@ func TestHostsDiscoveryRule(t *testing.T) {
testHost(t, params)
}

func TestHostsGraphs(t *testing.T) {
func TestHostsGraphsIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectGraphs: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsHostDiscovery(t *testing.T) {
func TestHostsHostDiscoveryIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectHostDiscovery: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsWebScenarios(t *testing.T) {
func TestHostsWebScenariosIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectWebScenarios: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsInterfaces(t *testing.T) {
func TestHostsInterfacesIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectInterfaces: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsInventory(t *testing.T) {
func TestHostsInventoryIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectInventory: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsItems(t *testing.T) {
func TestHostsItemsIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectItems: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsMacros(t *testing.T) {
func TestHostsMacrosIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectMacros: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsParentTemplates(t *testing.T) {
func TestHostsParentTemplatesIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectParentTemplates: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsScreens(t *testing.T) {
func TestHostsScreensIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectScreens: zabbix.SelectExtendedOutput,
}

testHost(t, params)
}

func TestHostsTriggers(t *testing.T) {
func TestHostsTriggersIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

params := zabbix.HostGetParams{
SelectTriggers: zabbix.SelectExtendedOutput,
}
Expand Down
6 changes: 5 additions & 1 deletion test/integration/items_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
"github.com/fabiang/go-zabbix/test"
)

func TestItems(t *testing.T) {
func TestItemsIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

session := test.GetTestSession(t)

params := zabbix.ItemGetParams{}
Expand Down
6 changes: 5 additions & 1 deletion test/integration/maintenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
"github.com/fabiang/go-zabbix/test"
)

func TestMaintenance(t *testing.T) {
func TestMaintenanceIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

session := test.GetTestSession(t)

params := zabbix.MaintenanceGetParams{}
Expand Down
6 changes: 5 additions & 1 deletion test/integration/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
"github.com/fabiang/go-zabbix/test"
)

func TestProxy(t *testing.T) {
func TestProxyIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

session := test.GetTestSession(t)

params := zabbix.ProxyGetParams{}
Expand Down
6 changes: 5 additions & 1 deletion test/integration/trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
"github.com/fabiang/go-zabbix/test"
)

func TestTriggers(t *testing.T) {
func TestTriggersIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

session := test.GetTestSession(t)

params := zabbix.TriggerGetParams{}
Expand Down
6 changes: 5 additions & 1 deletion test/integration/usermacros_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
"github.com/fabiang/go-zabbix/test"
)

func TestUserMacros(t *testing.T) {
func TestUserMacrosIntegration(t *testing.T) {
if testing.Short() {
t.Skip()
}

session := test.GetTestSession(t)

params := zabbix.UserMacroGetParams{}
Expand Down

0 comments on commit 277fde5

Please sign in to comment.