Skip to content

Commit

Permalink
fix(tests): run integration tests on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Dec 7, 2023
1 parent 44ef6f7 commit 73c7472
Show file tree
Hide file tree
Showing 20 changed files with 83 additions and 3 deletions.
12 changes: 12 additions & 0 deletions testscript/script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func TestScript(t *testing.T) {
"dos2unix": cmdDos2Unix,
"new-webhook": cmdNewWebhook,
"waitforserver": cmdWaitforserver,
"stopserver": cmdStopserver,
},
Setup: func(e *testscript.Env) error {
// Add binPath to PATH
Expand All @@ -116,6 +117,9 @@ func TestScript(t *testing.T) {
e.Setenv("SSH_KNOWN_HOSTS_FILE", filepath.Join(t.TempDir(), "known_hosts"))
e.Setenv("SSH_KNOWN_CONFIG_FILE", filepath.Join(t.TempDir(), "config"))

// This is used to set up test specific configuration and http endpoints
e.Setenv("SOFT_SERVE_TESTRUN", "1")

// Soft Serve debug environment variables
for _, env := range []string{
"SOFT_SERVE_DEBUG",
Expand Down Expand Up @@ -418,6 +422,14 @@ func cmdWaitforserver(ts *testscript.TestScript, neg bool, args []string) {
}
}

func cmdStopserver(ts *testscript.TestScript, neg bool, args []string) {
// stop the server
resp, err := http.DefaultClient.Head(fmt.Sprintf("%s/__stop", ts.Getenv("SOFT_SERVE_HTTP_PUBLIC_URL")))
check(ts, err, neg)
defer resp.Body.Close()
time.Sleep(time.Second * 2) // Allow some time for the server to stop
}

func setupPostgres(t testscript.T, cfg *config.Config) (error, func()) {
// Indicates postgres
// Create a disposable database
Expand Down
4 changes: 4 additions & 0 deletions testscript/testdata/help.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ waitforserver
soft --help
cmpenv stdout help.txt

# stop the server
[windows] stopserver
[windows] ! stderr .

-- help.txt --
Soft Serve is a self-hostable Git server for the command line.

Expand Down
4 changes: 4 additions & 0 deletions testscript/testdata/http.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ stdout '404.*'
curl http://$TOKEN@localhost:$HTTP_PORT/repo2.git?go-get=1
cmpenv stdout goget.txt

# stop the server
[windows] stopserver
[windows] ! stderr .

-- http1.txt --
{"transfer":"basic","objects":[{"oid":"","size":0,"error":{"code":422,"message":"invalid object"}}],"hash_algo":"sha256"}
-- http2.txt --
Expand Down
4 changes: 4 additions & 0 deletions testscript/testdata/jwt.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ usoft jwt
stdout '.*\..*\..*'
usoft jwt repo
stdout '.*\..*\..*'

# stop the server
[windows] stopserver
[windows] ! stderr .
4 changes: 4 additions & 0 deletions testscript/testdata/mirror.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ cmp stdout info2.txt
soft repo blob charmbracelet/test LICENSE
stdout '.*Creative Commons.*'

# stop the server
[windows] stopserver
[windows] ! stderr .


-- info1.txt --
Project Name:
Expand Down
3 changes: 3 additions & 0 deletions testscript/testdata/repo-blob.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ stderr 'revision does not exist'
! stdout .
stderr 'revision does not exist'

# stop the server
[windows] stopserver

-- blob1.txt --
# Hello\n\nwelcome
-- blob2.txt --
Expand Down
4 changes: 4 additions & 0 deletions testscript/testdata/repo-collab.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ stdout 'foo'
soft repo collab remove test foo
soft repo collab list test
! stdout .

# stop the server
[windows] stopserver
[windows] ! stderr .
4 changes: 4 additions & 0 deletions testscript/testdata/repo-commit.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ soft repo import basic1 https://github.com/git-fixtures/basic
soft repo commit basic1 b8e471f58bcbca63b07bda20e428190409c2db47
cmp stdout commit1.txt

# stop the server
[windows] stopserver
[windows] ! stderr .

-- commit1.txt --
commit b8e471f58bcbca63b07bda20e428190409c2db47
Author: Daniel Ripolles
Expand Down
4 changes: 4 additions & 0 deletions testscript/testdata/repo-create.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ stdout 'repo2'
usoft repo delete repo2
! exists $DATA_PATH/repos/repo2.git

# stop the server
[windows] stopserver
[windows] ! stderr .


-- readme.md --
# Project\nfoo
Expand Down
4 changes: 4 additions & 0 deletions testscript/testdata/repo-delete.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ soft repo delete repo-to-delete
stderr '.*not found.*'
soft repo list
stdout 'repo1'

# stop the server
[windows] stopserver
[windows] ! stderr .
4 changes: 4 additions & 0 deletions testscript/testdata/repo-import.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ soft repo import --name 'repo33' --description 'descriptive' repo3 https://githu
soft repo info repo3
cmp stdout repo3.txt

# stop the server
[windows] stopserver
[windows] ! stderr .

-- repo3.txt --
Project Name: repo33
Repository: repo3
Expand Down
4 changes: 4 additions & 0 deletions testscript/testdata/repo-perms.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ usoft repo delete repo1
usoft repo list
! stdout .

# stop the server
[windows] stopserver
[windows] ! stderr .

-- info.txt --
Project Name: proj
Repository: repo1
Expand Down
6 changes: 3 additions & 3 deletions testscript/testdata/repo-push.txtar
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# vi: set ft=conf

# convert crlf to lf on windows
[windows] dos2unix

# start soft serve
exec soft serve &
# wait for server to start
Expand All @@ -16,3 +13,6 @@ git clone ssh://localhost:$SSH_PORT/repo-empty repo-empty

# push repo
! git -C repo-empty push origin HEAD

# stop the server
[windows] stopserver
3 changes: 3 additions & 0 deletions testscript/testdata/repo-tree.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ stderr 'file not found'
! stdout .
stderr 'revision does not exist'

# stop the server
[windows] stopserver

-- tree1.txt --
drwxrwxrwx - folder
-rw-r--r-- - .hidden
Expand Down
4 changes: 4 additions & 0 deletions testscript/testdata/repo-webhooks.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ git -C repo-123 push origin HEAD
# list webhook deliveries
soft repo webhook deliver list repo-123 1
stdout '✅.*push.*'

# stop the server
[windows] stopserver
[windows] ! stderr .
4 changes: 4 additions & 0 deletions testscript/testdata/set-username.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ soft set-username test
soft info
cmpenv stdout info2.txt

# stop the server
[windows] stopserver
[windows] ! stderr .

-- info1.txt --
Username: admin
Admin: true
Expand Down
3 changes: 3 additions & 0 deletions testscript/testdata/settings.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ stdout 'admin-access.*'
! stdout .
stderr .

# stop the server
[windows] stopserver

4 changes: 4 additions & 0 deletions testscript/testdata/ssh.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ stdout '.*header.*Bearer.*href.*expires_in.*expires_at.*'
usoft git-lfs-authenticate repo2p upload
stdout '.*header.*Bearer.*href.*expires_in.*expires_at.*'

# stop the server
[windows] stopserver
[windows] ! stderr .

-- argserr1.txt --
Error: accepts 1 arg(s), received 0
-- argserr2.txt --
Expand Down
3 changes: 3 additions & 0 deletions testscript/testdata/token.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ usoft token delete 1
stderr 'Access token deleted'
! usoft token delete 1
stderr 'token not found'

# stop the server
[windows] stopserver
4 changes: 4 additions & 0 deletions testscript/testdata/user_management.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ soft user delete foo2
soft user list
cmpenv stdout list1.txt

# stop the server
[windows] stopserver
[windows] ! stderr .


-- info.txt --
Username: admin
Expand Down

0 comments on commit 73c7472

Please sign in to comment.