/ tests / frontend / update.sh
update.sh
  1  #! /usr/bin/env atf-sh
  2  
  3  . $(atf_get_srcdir)/test_environment.sh
  4  
  5  tests_init \
  6  	update_error \
  7  	file_url \
  8  
  9  update_error_body() {
 10  
 11  	mkdir repos
 12  	mkdir empty
 13  	cat > repos/test.conf << EOF
 14  test: {
 15    url: "file://empty/",
 16  }
 17  EOF
 18  
 19  	atf_check \
 20  		-o match:"Unable to update repository test" \
 21  		-e match:"Invalid URL: 'file://empty//meta.conf'" \
 22  		-s exit:1 \
 23  		pkg -R repos update
 24  }
 25  
 26  file_url_body() {
 27  	mkdir repos
 28  	touch meta.conf
 29  	here=$(pwd)
 30  
 31  
 32  #
 33  # test file:/empty/, which is invalid
 34  #
 35  	cat > repos/test.conf << EOF
 36  test: {
 37    url: "file:/empty/",
 38  }
 39  EOF
 40  
 41  	atf_check \
 42  		-o match:"Unable to update repository test" \
 43  		-e match:"Invalid URL: 'file:/empty//meta.conf" \
 44  		-s exit:1 \
 45  		pkg -R repos update
 46  
 47  #
 48  # test file://here, which is invalid
 49  #
 50  	cat > repos/test.conf << EOF
 51  test: {
 52    url: "file://here",
 53  }
 54  EOF
 55  	atf_check \
 56  		-o match:"Unable to update repository test" \
 57  		-e match:"Invalid URL: 'file://here/meta.conf'" \
 58  		-s exit:1 \
 59  		pkg -R repos update
 60  
 61  
 62  #
 63  # test file://here//path, which is invalid
 64  #
 65  	cat > repos/test.conf << EOF
 66  test: {
 67    url: "file://here/${here}",
 68  }
 69  EOF
 70  	atf_check \
 71  		-o match:"Unable to update repository test" \
 72  		-e not-match:"meta.*No such file or directory" \
 73  		-s exit:1 \
 74  		pkg -R repos update
 75  
 76  #
 77  # test file:////path, which is valid
 78  #
 79  	cat > repos/test.conf << EOF
 80  test: {
 81    url: "file:///${here}",
 82  }
 83  EOF
 84  
 85  	atf_check \
 86  		-o match:"Unable to update repository test" \
 87  		-e not-match:"meta.*No such file or directory" \
 88  		-s exit:1 \
 89  		pkg -R repos update
 90  
 91  #
 92  # test file:///path, which is valid
 93  #
 94  	cat > repos/test.conf << EOF
 95  test: {
 96    url: "file://${here}",
 97  }
 98  EOF
 99  
100  	atf_check \
101  		-o match:"Unable to update repository test" \
102  		-e not-match:"meta.*No such file or directory" \
103  		-s exit:1 \
104  		pkg -R repos update
105  
106  #
107  # test file://path, which is invalid
108  #
109  	cat > repos/test.conf << EOF
110  test: {
111    url: "file:/${here}",
112  }
113  EOF
114  
115  	atf_check \
116  		-o match:"Unable to update repository test" \
117  		-e match:"Invalid URL: 'file:/${here}/meta.conf'" \
118  		-s exit:1 \
119  		pkg -R repos update
120  
121  
122  #
123  # test file://localhost/path, which is a valid
124  #
125  	cat > repos/test.conf << EOF
126  test: {
127    url: "file://localhost${here}",
128  }
129  EOF
130  
131  	atf_check \
132  		-o match:"Unable to update repository test" \
133  		-e not-match:"meta.*No such file or directory" \
134  		-s exit:1 \
135  		pkg -R repos update
136  
137  }