mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-18 14:34:23 +01:00
Add TestSuite Model with Serialization and Deserialization Support
This commit introduces a new class, TestSuite, designed to encapsulate a collection of Task objects under a common timestamp. This will help in grouping tasks that belong to a particular test suite. Key Features: - Add a TestSuite class with fields for `timestamp` and a list of `tests` (Task objects). - Implement `toJson` method for serializing TestSuite objects to JSON-compatible format. - Implement `fromJson` factory method for deserializing JSON data back into a TestSuite object. By providing serialization and deserialization support directly in the model, we facilitate easier storage and data exchange for test suites.
This commit is contained in:
25
frontend/lib/models/test_suite.dart
Normal file
25
frontend/lib/models/test_suite.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import 'package:auto_gpt_flutter_client/models/task.dart';
|
||||
|
||||
class TestSuite {
|
||||
final String timestamp;
|
||||
final List<Task> tests;
|
||||
|
||||
TestSuite({required this.timestamp, required this.tests});
|
||||
|
||||
// Serialization: Convert the object into a Map
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'timestamp': timestamp,
|
||||
'tests': tests.map((task) => task.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
|
||||
// Deserialization: Create an object from a Map
|
||||
factory TestSuite.fromJson(Map<String, dynamic> json) {
|
||||
return TestSuite(
|
||||
timestamp: json['timestamp'],
|
||||
tests: List<Task>.from(json['tests'].map(
|
||||
(taskJson) => Task.fromMap(Map<String, dynamic>.from(taskJson)))),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user