Skip to content

Commit

Permalink
skip win
Browse files Browse the repository at this point in the history
  • Loading branch information
hyorigo committed Jul 22, 2024
1 parent 4d1563a commit 5dd05eb
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/net/network_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
package net_test

import (
"runtime"
"testing"

itn "github.com/1set/starlet/internal"
"github.com/1set/starlet/lib/net"
)

func TestLoadModule_Network(t *testing.T) {
isOnWindows := runtime.GOOS == "windows"
tests := []struct {
name string
script string
wantErr string
name string
script string
wantErr string
skipWindows bool
}{
{
name: `nslookup: normal`,
Expand Down Expand Up @@ -79,9 +82,10 @@ func TestLoadModule_Network(t *testing.T) {
name: `nslookup: wrong dns`,
script: itn.HereDoc(`
load('net', 'nslookup')
ips = nslookup('bing.com', 'apple.com', timeout=1)
ips = nslookup('bing.com', 'microsoft.com', timeout=1)
`),
wantErr: `i/o timeout`,
wantErr: `i/o timeout`,
skipWindows: true,
},
{
name: `nslookup: no args`,
Expand Down Expand Up @@ -113,7 +117,7 @@ func TestLoadModule_Network(t *testing.T) {
name: `tcping: abnormal`,
script: itn.HereDoc(`
load('net', 'tcping')
s = tcping('apple.com', count=1, timeout=-5, interval=-2)
s = tcping('bing.com', count=1, timeout=-5, interval=-2)
print(s)
assert.eq(s.total, 1)
assert.true(s.success > 0)
Expand Down Expand Up @@ -165,6 +169,10 @@ func TestLoadModule_Network(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if isOnWindows && tt.skipWindows {
t.Skipf("Skip test on Windows")
return
}
res, err := itn.ExecModuleWithErrorTest(t, net.ModuleName, net.LoadModule, tt.script, tt.wantErr, nil)
if (err != nil) != (tt.wantErr != "") {
t.Errorf("net(%q) expects error = '%v', actual error = '%v', result = %v", tt.name, tt.wantErr, err, res)
Expand Down

0 comments on commit 5dd05eb

Please sign in to comment.