Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Test cases #9

Merged
merged 15 commits into from
Jul 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions ballerina/tests/tests.bal
HussainLatiff marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Copyright (c) 2024 WSO2 LLC. (http://www.wso2.org).
//
// WSO2 LLC. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/test;

configurable string clientId = "Client ID";
configurable string clientSecret = "Client Secret";
configurable string[] scopes = ?;
HussainLatiff marked this conversation as resolved.
Show resolved Hide resolved

// Test case for the endpoint for exchanging authorization code for tokens
HussainLatiff marked this conversation as resolved.
Show resolved Hide resolved
@test:Config{}
function testGetToken() returns error? {
Client discord =check new({
auth: {
clientId: clientId,
clientSecret: clientSecret,
scopes: ["identify"]
}
});

OAuth2GetKeys getToken = check discord->/oauth2/keys();
}

// Test case for the endpoint to retrieve details about a specific user
@test:Config{}
function testGetUser() returns error? {
string user_id = "User ID";
Client discord =check new({
HussainLatiff marked this conversation as resolved.
Show resolved Hide resolved
auth: {
clientId: clientId,
clientSecret: clientSecret,
scopes: ["identify", "email"]
}
});

UserResponse getUserInfo = check discord->/users/[user_id]();
}

// Test case for the endpoint to retrieve details about a specific guild
@test:Config{}
function testGetGuild() returns error? {
string guild_id = "Guild ID";
Client discord =check new({
auth: {
clientId: clientId,
clientSecret: clientSecret,
scopes: ["guilds"]
}
});

PrivateGuildMemberResponse getGuildInfo = check discord->/users/\@me/guilds/[guild_id]/member();
}

// Test case for the endpoint to edit a message
@test:Config{}
function testGetChannel() returns error? {
string channel_id = "Text Channel ID";
string message_id = "Message ID";
Client discord =check new({
auth: {
clientId: clientId,
clientSecret: clientSecret,
scopes: ["guilds"]
}
});

MessageResponse getGuildChannel = check discord->/channels/[channel_id]/messages/[message_id]();
}

// Test case for the endpoint to create a voice channel invite
@test:Config{}
function testGetVoiceChannel() returns error? {
string channel_id = "Voice Channel ID";
Client discord =check new({
auth: {
clientId: clientId,
clientSecret: clientSecret,
scopes: ["voice"]
}
});

var getVoiceChannelInfo = check discord->/channels/[channel_id]/invites();
HussainLatiff marked this conversation as resolved.
Show resolved Hide resolved
}
HussainLatiff marked this conversation as resolved.
Show resolved Hide resolved
Loading