50 lines
1.7 KiB
Dart
50 lines
1.7 KiB
Dart
import 'package:dio/dio.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
test('Test Zipcode API structure', () async {
|
|
final dio = Dio();
|
|
dio.options.baseUrl = 'http://43.201.34.104:8080/api/v1';
|
|
|
|
try {
|
|
// 먼저 로그인해서 토큰을 받자
|
|
final loginResponse = await dio.post('/auth/login', data: {
|
|
'email': 'admin@example.com',
|
|
'password': 'password123'
|
|
});
|
|
|
|
final token = loginResponse.data['access_token'];
|
|
dio.options.headers['Authorization'] = 'Bearer $token';
|
|
|
|
// Zipcodes API 테스트 - 검색 매개변수로 테스트
|
|
final zipcodesResponse = await dio.get('/zipcodes', queryParameters: {
|
|
'search': '서울',
|
|
'limit': 5
|
|
});
|
|
|
|
print('=== Zipcodes API 응답 구조 ===');
|
|
print('상태 코드: ${zipcodesResponse.statusCode}');
|
|
print('응답 데이터 타입: ${zipcodesResponse.data.runtimeType}');
|
|
print('응답 내용: ${zipcodesResponse.data}');
|
|
|
|
if (zipcodesResponse.data is Map) {
|
|
final data = zipcodesResponse.data as Map<String, dynamic>;
|
|
print('응답 키: ${data.keys.toList()}');
|
|
|
|
if (data['data'] is List && (data['data'] as List).isNotEmpty) {
|
|
final firstItem = (data['data'] as List).first;
|
|
print('첫 번째 우편번호 구조: $firstItem');
|
|
print('첫 번째 우편번호 키: ${firstItem.keys.toList()}');
|
|
}
|
|
}
|
|
|
|
} catch (e) {
|
|
if (e is DioException) {
|
|
print('API 에러: ${e.response?.statusCode}');
|
|
print('에러 메시지: ${e.response?.data}');
|
|
} else {
|
|
print('예상치 못한 에러: $e');
|
|
}
|
|
}
|
|
});
|
|
} |