-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
103 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Package pwcompat provides a compatibility layer, so when the playwright-go | ||
// team decides to break compatibility again, there's a place to write a | ||
// workaround. | ||
// | ||
//go:build: darwin | ||
package pwcompat | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
func bailonerr(t *testing.T, err error) { | ||
t.Helper() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
|
||
func Test_getDefaultCacheDirectory(t *testing.T) { | ||
t.Parallel() | ||
home, err := os.UserHomeDir() | ||
bailonerr(t, err) | ||
tests := []struct { | ||
name string | ||
want string | ||
wantErr bool | ||
}{ | ||
{ | ||
"darwin", | ||
filepath.Join(home, "Library", "Caches"), | ||
false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
t.Parallel() | ||
got, err := getDefaultCacheDirectory() | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("getDefaultCacheDirectory() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if got != tt.want { | ||
t.Errorf("getDefaultCacheDirectory() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Package pwcompat provides a compatibility layer, so when the playwright-go | ||
// team decides to break compatibility again, there's a place to write a | ||
// workaround. | ||
package pwcompat | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/playwright-community/playwright-go" | ||
) | ||
|
||
func TestNewDriver(t *testing.T) { | ||
t.Parallel() | ||
type args struct { | ||
runopts *playwright.RunOptions | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
wantErr bool | ||
}{ | ||
{ | ||
"default dir", | ||
args{&playwright.RunOptions{ | ||
DriverDirectory: "", | ||
SkipInstallBrowsers: true, | ||
Browsers: []string{"chrome"}}, | ||
}, | ||
false, | ||
}, | ||
{ | ||
"custom dir", | ||
args{&playwright.RunOptions{ | ||
DriverDirectory: t.TempDir(), | ||
SkipInstallBrowsers: true, | ||
Browsers: []string{"chrome"}}, | ||
}, | ||
false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
t.Parallel() | ||
_, err := NewDriver(tt.args.runopts) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("NewDriver() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters