pace_listbox_mirrors_test.vala 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* -*- Mode: Vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
  2. using Pace;
  3. using IniParser;
  4. class PaceListBoxMirrorsTest {
  5. public static int main ( string[] args ) {
  6. Test.init ( ref args );
  7. if ( !Gtk.init_check ( ref args ) )
  8. {
  9. return 77; //meson exit code to skip test
  10. }
  11. PaceListBoxMirrorsTest.add_tests ();
  12. string file_content = "Server = value\n" +
  13. "#Server = value2\n";
  14. try {
  15. FileUtils.set_contents ( "pace_listbox_mirrors_test.conf", file_content );
  16. } catch ( Error e ) {
  17. stderr.printf ( "Error creating mirrorlist file (%s)\n", e.message );
  18. }
  19. Test.run ();
  20. return 0;
  21. }
  22. public static void add_tests () {
  23. Test.add_func ( "/pace/listbox_mirrors", () => {
  24. ListBoxMirrors test_listbox = new ListBoxMirrors ( "pace_listbox_mirrors_test.conf" );
  25. assert ( test_listbox is ListBoxMirrors );
  26. } );
  27. Test.add_func ( "/pace/listbox_options/set_mirrors/get_mirrors", () => {
  28. bool check = true;
  29. ListBoxMirrors test_listbox = new ListBoxMirrors ( "pace_listbox_mirrors_test.conf" );
  30. Array<Key> mirrors = test_listbox.get_mirrorlist_file ().get_no_section_keys ();
  31. check = check && mirrors.index ( 0 ).to_string () == "Server = value\n";
  32. check = check && mirrors.index ( 1 ).to_string () == "# Server = value2\n";
  33. assert ( check );
  34. } );
  35. }
  36. }