Skip to content

Commit 8e38fe2

Browse files
[TASKSCLOUD-497] - Added tests for WBS endpoints.
1 parent ea289a6 commit 8e38fe2

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

tests/wbs_test.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* --------------------------------------------------------------------------------
3+
* <copyright company="Aspose" file="wbs_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 wbs.
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+
"testing"
36+
)
37+
38+
// Test for get wbs definition.
39+
func Test_Wbs_GetWbsDefinition(t *testing.T) {
40+
localFileName := "WBSDefinition.mpp"
41+
remoteFileName := CreateRandomGuid() + localFileName
42+
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
43+
44+
opts := &requests.GetWbsDefinitionOpts{
45+
Name: remoteFileName,
46+
Folder: optional.NewString(remoteBaseTestDataFolder),
47+
}
48+
result, _, err := client.TasksApi.GetWbsDefinition(ctx, opts)
49+
if err != nil {
50+
t.Error(err)
51+
}
52+
assert.Equal(t, int32(200), result.Code)
53+
assert.NotNil(t, result.WbsDefinition)
54+
assert.True(t, result.WbsDefinition.GenerateWBSCode)
55+
assert.True(t, result.WbsDefinition.VerifyUniqueness)
56+
t.Cleanup(func() { DeleteTestFileFromStorage(t, ctx, client) })
57+
}
58+
59+
// Test for put renumber wbs code.
60+
func Test_Wbs_PutRenumberWbsCode(t *testing.T) {
61+
localFileName := "WBSDefinition.mpp"
62+
remoteFileName := CreateRandomGuid() + localFileName
63+
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
64+
65+
opts := &requests.PutRenumberWbsCodeOpts{
66+
TaskUids: []int32{},
67+
Name: remoteFileName,
68+
Folder: optional.NewString(remoteBaseTestDataFolder),
69+
}
70+
result, _, err := client.TasksApi.PutRenumberWbsCode(ctx, opts)
71+
if err != nil {
72+
t.Error(err)
73+
}
74+
assert.Equal(t, int32(200), result.Code)
75+
t.Cleanup(func() { DeleteTestFileFromStorage(t, ctx, client) })
76+
}

0 commit comments

Comments
 (0)