test-direct.jsโข2.07 kB
// Direct function call testing (bypasses MCP protocol)
import { markAttendance } from './src/tools/attendanceTools.js';
import { commitChanges, getRepoInfo } from './src/tools/githubTools.js';
import 'dotenv/config';
// Test mark_attendance
async function testMarkAttendance() {
console.log('๐งช Testing mark_attendance...');
try {
const result = await markAttendance({
studentId: '12345',
date: '2024-01-15',
status: 'present'
});
console.log('โ
Success:', JSON.stringify(result, null, 2));
} catch (error) {
console.error('โ Error:', error.message);
}
}
// Test get_repo_info
async function testGetRepoInfo() {
console.log('\n๐งช Testing get_repo_info...');
try {
const result = await getRepoInfo({
repoOwner: 'sadaf987',
repoName: 'test_MCP'
});
console.log('โ
Success:', JSON.stringify(result, null, 2));
} catch (error) {
console.error('โ Error:', error.message);
}
}
// Test commit_changes
async function testCommitChanges() {
console.log('\n๐งช Testing commit_changes...');
try {
const result = await commitChanges({
repoOwner: 'sadaf987',
repoName: 'github_sdk',
branchName: 'main',
commitMessage: 'Test commit from direct function call',
filesToCommit: [
{
path: 'test-direct.txt',
content: 'This file was created via direct function call\nTimestamp: ' + new Date().toISOString()
}
]
});
console.log('โ
Success:', JSON.stringify(result, null, 2));
} catch (error) {
console.error('โ Error:', error.message);
}
}
// Run all tests
async function runTests() {
console.log('='.repeat(50));
console.log('Direct Function Call Testing');
console.log('='.repeat(50));
await testMarkAttendance();
await testGetRepoInfo();
// Uncomment to test commit (requires valid GitHub token)
// await testCommitChanges();
console.log('\n' + '='.repeat(50));
console.log('Testing Complete');
console.log('='.repeat(50));
}
runTests().catch(console.error);