-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(build): rollback implementation (#30)
Signed-off-by: Ruslan Semagin <[email protected]>
- Loading branch information
Showing
2 changed files
with
141 additions
and
8 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,87 @@ | ||
package internal | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func Test_makeZipFilePath(t *testing.T) { | ||
mod1 := &Module{ | ||
BuildDirectory: "testdata", | ||
Version: "1.0.0", | ||
} | ||
|
||
mod2 := &Module{ | ||
BuildDirectory: "testdata/build", | ||
Version: "1.0.1", | ||
} | ||
|
||
cur, _ := os.Getwd() | ||
|
||
type args struct { | ||
module *Module | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want string | ||
wantErr bool | ||
}{ | ||
{"1", args{mod1}, fmt.Sprintf("%s/testdata/1.0.0.zip", cur), false}, | ||
{"2", args{mod2}, fmt.Sprintf("%s/testdata/build/1.0.1.zip", cur), false}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := makeZipFilePath(tt.args.module) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("makeZipFilePath() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if got != tt.want { | ||
t.Errorf("makeZipFilePath() got = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func Test_makeVersionDirectory(t *testing.T) { | ||
mod1 := &Module{ | ||
BuildDirectory: "testdata", | ||
Version: "1.0.0", | ||
} | ||
|
||
mod2 := &Module{ | ||
BuildDirectory: "testdata/build", | ||
Version: "1.0.1", | ||
} | ||
|
||
cur, _ := os.Getwd() | ||
|
||
type args struct { | ||
module *Module | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want string | ||
wantErr bool | ||
}{ | ||
{"1", args{mod1}, fmt.Sprintf("%s/testdata/1.0.0", cur), false}, | ||
{"2", args{mod2}, fmt.Sprintf("%s/testdata/build/1.0.1", cur), false}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := makeVersionDirectory(tt.args.module) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("makeVersionDirectory() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if got != tt.want { | ||
t.Errorf("makeVersionDirectory() got = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |