Skip to content

Commit

Permalink
Update test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
CYHFREDA authored Oct 15, 2024
1 parent 777069b commit d46f2a9
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions backend/test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
const axios = require('axios');

// 假設這是你的業務邏輯函數
function runBusinessLogic() {
function runBusinessLogic(input) {
// 這裡可以放置你的業務邏輯
return '程式碼運行順利!';
return `處理的結果: ${input}`;
}

// 進行簡單測試
try {
const result = runBusinessLogic();
console.log(result);
process.exit(0); // 正常退出
} catch (error) {
console.error('測試失敗:', error);
process.exit(1); // 當有錯誤發生時返回非零退出碼
}
// 從 API 獲取測試數據
axios.get('https://api.example.com/test-data')
.then(response => {
const testData = response.data;
try {
const result = runBusinessLogic(testData);
console.log(result);
process.exit(0); // 正常退出
} catch (error) {
console.error('測試失敗:', error);
process.exit(1); // 當有錯誤發生時返回非零退出碼
}
})
.catch(error => {
console.error('無法獲取測試數據:', error);
process.exit(1); // 當有錯誤發生時返回非零退出碼
});

0 comments on commit d46f2a9

Please sign in to comment.