Files
Auto-GPT/frontend/lib/models/test_suite.dart
hunteraraujo 1d735caf40 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.
2023-09-18 14:41:25 -07:00

26 lines
694 B
Dart

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)))),
);
}
}