forked from mat007/go-msi
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dynamic directory and file detection
- Loading branch information
jsirianni
committed
Feb 19, 2022
1 parent
5b988ff
commit 82be605
Showing
15 changed files
with
318 additions
and
1 deletion.
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
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,123 @@ | ||
package manifest | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestBuilDirectories(t *testing.T) { | ||
wixFile := &WixManifest{} | ||
wixFile.Directories = []Directory{ | ||
{ | ||
Name: "testdata", | ||
}, | ||
{ | ||
Name: "testdata2", | ||
}, | ||
} | ||
|
||
err := wixFile.buildDirectoriesRecursive() | ||
require.NoError(t, err) | ||
require.Equal(t, "testdata", wixFile.Directories[0].Name) | ||
|
||
expect := &WixManifest{} | ||
expect.Directories = []Directory{ | ||
{ | ||
Name: "testdata", | ||
Directories: []Directory{ | ||
{ | ||
Name: "path_a", | ||
Files: []File{ | ||
{ | ||
Path: "testdata/path_a/a", | ||
}, | ||
{ | ||
Path: "testdata/path_a/a2", | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "path_b", | ||
Files: []File{ | ||
{ | ||
Path: "testdata/path_b/b", | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "path_c", | ||
Directories: []Directory{ | ||
{ | ||
Name: "path_c_sub", | ||
Files: []File{ | ||
{ | ||
Path: "testdata/path_c/path_c_sub/csub", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
Files: []File{ | ||
{ | ||
Path: "testdata/testdata", | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "testdata2", | ||
Directories: []Directory{ | ||
{ | ||
Name: "path_a", | ||
Files: []File{ | ||
{ | ||
Path: "testdata2/path_a/a", | ||
}, | ||
{ | ||
Path: "testdata2/path_a/a2", | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "path_b", | ||
Files: []File{ | ||
{ | ||
Path: "testdata2/path_b/b", | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "path_c", | ||
Directories: []Directory{ | ||
{ | ||
Name: "path_c_sub", | ||
Files: []File{ | ||
{ | ||
Path: "testdata2/path_c/path_c_sub/csub", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
Files: []File{ | ||
{ | ||
Path: "testdata2/testdata", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
require.Equal(t, expect, wixFile) | ||
|
||
} | ||
|
||
func TestEmptyDir(t *testing.T) { | ||
wixFile := &WixManifest{} | ||
d := Directory{Name: "fakedir"} | ||
wixFile.Directories = append(wixFile.Directories, d) | ||
|
||
err := wixFile.buildDirectoriesRecursive() | ||
require.Error(t, err) | ||
} |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
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,92 @@ | ||
{ | ||
"product": "", | ||
"company": "", | ||
"upgrade-code": "", | ||
"directories": [ | ||
{ | ||
"name": "testdata", | ||
"files": [ | ||
{ | ||
"path": "testdata/testdata" | ||
} | ||
], | ||
"directories": [ | ||
{ | ||
"name": "path_a", | ||
"files": [ | ||
{ | ||
"path": "testdata/path_a/a" | ||
}, | ||
{ | ||
"path": "testdata/path_a/a2" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "path_b", | ||
"files": [ | ||
{ | ||
"path": "testdata/path_b/b" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "path_c", | ||
"directories": [ | ||
{ | ||
"name": "path_c_sub", | ||
"files": [ | ||
{ | ||
"path": "testdata/path_c/path_c_sub/csub" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "testdata2", | ||
"files": [ | ||
{ | ||
"path": "testdata2/testdata" | ||
} | ||
], | ||
"directories": [ | ||
{ | ||
"name": "path_a", | ||
"files": [ | ||
{ | ||
"path": "testdata2/path_a/a" | ||
}, | ||
{ | ||
"path": "testdata2/path_a/a2" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "path_b", | ||
"files": [ | ||
{ | ||
"path": "testdata2/path_b/b" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "path_c", | ||
"directories": [ | ||
{ | ||
"name": "path_c_sub", | ||
"files": [ | ||
{ | ||
"path": "testdata2/path_c/path_c_sub/csub" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"choco": {} | ||
} |