mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-27 19:04:25 +01:00
This commit adds the TaskRequestBody class, which is designed to encapsulate the request body when creating a new task. The class includes a toJson method for easy serialization to JSON format. Additionally, unit tests have been written to ensure that the TaskRequestBody object is created with the correct values and that it serializes to the expected JSON structure. - Added TaskRequestBody class with input and optional additionalInput fields. - Implemented toJson method for converting an instance of the class to JSON. - Added unit tests to verify both object creation and JSON serialization. These changes provide a standardized way to manage the request body when creating new tasks, improving the overall code quality and maintainability.
27 lines
831 B
Dart
27 lines
831 B
Dart
import 'package:auto_gpt_flutter_client/models/task_request_body.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
group('TaskRequestBody', () {
|
|
test('should create TaskRequestBody with correct values', () {
|
|
final taskRequestBody = TaskRequestBody(
|
|
input: 'Do something', additionalInput: {'key': 'value'});
|
|
|
|
expect(taskRequestBody.input, 'Do something');
|
|
expect(taskRequestBody.additionalInput, {'key': 'value'});
|
|
});
|
|
|
|
test('should convert TaskRequestBody to correct JSON', () {
|
|
final taskRequestBody = TaskRequestBody(
|
|
input: 'Do something', additionalInput: {'key': 'value'});
|
|
|
|
final json = taskRequestBody.toJson();
|
|
|
|
expect(json, {
|
|
'input': 'Do something',
|
|
'additional_input': {'key': 'value'}
|
|
});
|
|
});
|
|
});
|
|
}
|