Skip to content

Commit ea289a6

Browse files
[TASKSCLOUD-496] - Added tests for VBA endpoints.
1 parent 8f935f6 commit ea289a6

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

tests/vba_test.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* --------------------------------------------------------------------------------
3+
* <copyright company="Aspose" file="vba_test.go">
4+
* Copyright (c) 2021 Aspose.Tasks Cloud
5+
* </copyright>
6+
* <summary>
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
* </summary>
25+
* --------------------------------------------------------------------------------
26+
*/
27+
28+
// Example of how to work with vba.
29+
package api_test
30+
31+
import (
32+
"github.com/antihax/optional"
33+
"github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/api/requests"
34+
"github.com/stretchr/testify/assert"
35+
"strings"
36+
"testing"
37+
)
38+
39+
// Test for get vba project.
40+
func Test_Vba_GetVbaProject(t *testing.T) {
41+
localFileName := "VbaProject3.mpp"
42+
remoteFileName := CreateRandomGuid() + localFileName
43+
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
44+
45+
opts := &requests.GetVbaProjectOpts{
46+
Name: remoteFileName,
47+
Folder: optional.NewString(remoteBaseTestDataFolder),
48+
}
49+
result, _, err := client.TasksApi.GetVbaProject(ctx, opts)
50+
if err != nil {
51+
t.Error(err)
52+
}
53+
assert.Equal(t, int32(200), result.Code)
54+
assert.NotNil(t, result.VbaProject)
55+
assert.NotNil(t, result.VbaProject.Modules)
56+
assert.Equal(t, 7, len(result.VbaProject.Modules))
57+
assert.Equal(t, "Module1", result.VbaProject.Modules[0].Name)
58+
assert.True(t, strings.HasPrefix(result.VbaProject.Modules[0].SourceCode, "Type MEMORYSTATUS"))
59+
t.Cleanup(func() { DeleteTestFileFromStorage(t, ctx, client) })
60+
}

0 commit comments

Comments
 (0)