about summary refs log tree commit diff stats
path: root/075channel.mu
Commit message (Expand)AuthorAgeFilesLines
* 4261 - start using literals for 'true' and 'false'Kartik Agaram2018-06-171-5/+5
* 4242 - get rid of refcounts entirelyKartik Agaram2018-05-121-13/+5
* 4134 - 'input' = 'ingredient'Kartik K. Agaram2017-12-031-13/+13
* 3933Kartik K. Agaram2017-06-201-12/+12
* 3932Kartik K. Agaram2017-06-201-5/+25
* 3828 - make buffers shape-shifting (generic)Kartik K. Agaram2017-04-181-2/+2
* 3688Kartik K. Agaram2016-11-251-0/+3
* 3608 - concurrent writes to fake file systemKartik K. Agaram2016-10-291-0/+4
* 3552Kartik K. Agaram2016-10-221-1/+1
* 3527Kartik K. Agaram2016-10-201-1/+15
* 3429 - standardize Mu scenariosKartik K. Agaram2016-09-281-21/+22
* 3392Kartik K. Agaram2016-09-171-2/+2
* 3390Kartik K. Agaram2016-09-171-5/+5
* 3389Kartik K. Agaram2016-09-171-46/+46
* 3387Kartik K. Agaram2016-09-171-31/+31
* 3385Kartik K. Agaram2016-09-171-45/+45
* 3379Kartik K. Agaram2016-09-171-6/+6
* 3353Kartik K. Agaram2016-09-151-0/+5
* 3351 - new but incomplete synchronization setupKartik K. Agaram2016-09-141-21/+39
* 3337 - first use of type abbreviations: textKartik K. Agaram2016-09-121-1/+1
* 3258Kartik K. Agaram2016-08-261-4/+4
* 3231 - reading from fake files in scenariosKartik K. Agaram2016-08-201-0/+2
* 3225 - testable interface for writing filesKartik K. Agaram2016-08-181-1/+0
* 3194Kartik K. Agaram2016-08-161-2/+2
* 3154 - reorg before making 'random' more testableKartik K. Agaram2016-07-271-0/+452
ral.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdlib.h>

#include "plugins/disco.h"

void
returns_empty_list_when_none(void **state)
{
    disco_close();
    GList *features = disco_get_features();

    assert_int_equal(g_list_length(features), 0);

    g_list_free(features);
    disco_close();
}

void
returns_added_feature(void **state)
{
    disco_close();
    disco_add_feature("my_plugin", "some:feature:example");

    GList *features = disco_get_features();
    assert_int_equal(g_list_length(features), 1);
    char *feature = features->data;
    assert_string_equal(feature, "some:feature:example");

    g_list_free(features);
    disco_close();
}

void
resets_features_on_close(void **state)
{
    disco_close();
    disco_add_feature("my_plugin", "some:feature:example");

    GList *features = disco_get_features();
    assert_int_equal(g_list_length(features), 1);
    g_list_free(features);

    disco_close();
    features = disco_get_features();
    assert_int_equal(g_list_length(features), 0);

    g_list_free(features);
    disco_close();
}

void
returns_all_added_features(void **state)
{
    disco_close();
    disco_add_feature("first_plugin", "first:feature");
    disco_add_feature("first_plugin", "second:feature");
    disco_add_feature("second_plugin", "third:feature");
    disco_add_feature("third_plugin", "fourth:feature");
    disco_add_feature("third_plugin", "fifth:feature");

    GList *features = disco_get_features();

    assert_int_equal(g_list_length(features), 5);
    assert_true(g_list_find_custom(features, "first:feature", g_strcmp0));
    assert_true(g_list_find_custom(features, "second:feature", g_strcmp0));
    assert_true(g_list_find_custom(features, "third:feature", g_strcmp0));
    assert_true(g_list_find_custom(features, "fourth:feature", g_strcmp0));
    assert_true(g_list_find_custom(features, "fifth:feature", g_strcmp0));

    g_list_free(features);
    disco_close();
}

void
does_not_add_duplicate_feature(void **state)
{
    disco_close();
    disco_add_feature("my_plugin", "my:feature");
    disco_add_feature("some_other_plugin", "my:feature");

    GList *features = disco_get_features();
    assert_int_equal(g_list_length(features), 1);

    g_list_free(features);
    disco_close();
}

void
removes_plugin_features(void **state)
{
    disco_close();
    disco_add_feature("plugin1", "plugin1:feature1");
    disco_add_feature("plugin1", "plugin1:feature2");
    disco_add_feature("plugin2", "plugin2:feature1");

    GList *features = disco_get_features();
    assert_int_equal(g_list_length(features), 3);
    g_list_free(features);

    disco_remove_features("plugin1");

    features = disco_get_features();
    assert_int_equal(g_list_length(features), 1);

    g_list_free(features);
    disco_close();
}

void
does_not_remove_feature_when_more_than_one_reference(void **state)
{
    disco_close();
    disco_add_feature("plugin1", "feature1");
    disco_add_feature("plugin1", "feature2");
    disco_add_feature("plugin2", "feature1");

    GList *features = disco_get_features();
    assert_int_equal(g_list_length(features), 2);
    g_list_free(features);

    disco_remove_features("plugin1");

    features = disco_get_features();
    assert_int_equal(g_list_length(features), 1);

    g_list_free(features);
    disco_close();
}