summaryrefslogtreecommitdiff
path: root/test/tests.d/020_get
blob: 7fd30ba3117c6697d603e8c884b00fe7da7e1f5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
test_get_parsing()
{
	cp ${REF_DIR}/get_parsing.data ${CONFIG_DIR}/test

	assertFailWithNoReturn "${UCI_Q} get test."
	assertFailWithNoReturn "${UCI_Q} get test.section."
	assertFailWithNoReturn "${UCI_Q} get test.section.opt."
	assertFailWithNoReturn "${UCI_Q} get test.section.opt.val."
	assertFailWithNoReturn "${UCI_Q} get test.section.opt.val.qsdf.qsd"
	assertFailWithNoReturn "${UCI_Q} get test.section.opt.valqsqsd"
}

test_get_section_index_parsing()
{
	cp ${REF_DIR}/get_parsing.data ${CONFIG_DIR}/test

	assertFailWithNoReturn "${UCI_Q} get test.@"
	assertFailWithNoReturn "${UCI_Q} get test.@zer."
	assertFailWithNoReturn "${UCI_Q} get test.@."
	assertFailWithNoReturn "${UCI_Q} get test.@zer[1]"
	assertFailWithNoReturn "${UCI_Q} get test.@.opt"
	assertFailWithNoReturn "${UCI_Q} get test.@[28]"
	assertFailWithNoReturn "${UCI_Q} get test.@[1]."
	assertFailWithNoReturn "${UCI_Q} get test.@[1].val."
}

test_get_option()
{
	cp ${REF_DIR}/get.data ${CONFIG_DIR}/test
	value=$($UCI get test.section.opt)
	assertEquals 'val' "$value"
}

test_get_option_multiline()
{
	cp ${REF_DIR}/get_multiline.data ${CONFIG_DIR}/test
	value="$($UCI get test.section.opt)"
	echo "$value"
	assertEquals '"Hello, World.
'\''' "$value"
}

test_get_section()
{
	cp ${REF_DIR}/get.data ${CONFIG_DIR}/test
	type=$($UCI get test.section)
	assertEquals 'type' "$type"
}