added some git repo create validation
[gwvp-mini.git] / unittests / createlotsofreposandusers.php
index e69de29..f75e664 100644 (file)
@@ -0,0 +1,67 @@
+<?php
+$WEB_ROOT_FS = realpath(dirname(__FILE__));\r
+$BASE_URL = dirname($_SERVER["PHP_SELF"]);\r
+\r
+global $WEB_ROOT_FS, $BASE_URL, $data_directory, $db_type, $db_name, $db_username, $db_password;\r
+
+require_once("../www/config.php");\r
+\r
+if(file_exists("../gwvpmini/gwvpmini.php")) require_once("../gwvpmini/gwvpmini.php");\r
+else if(file_exists("/usr/share/gwvpmini/lib/gwvpmini/gwvpmini.php")) require_once("/usr/share/gwvpmini/lib/gwvpmini/gwvpmini.php");\r
+\r
+\r
+\r
+if(isset($noconfig)) {\r
+       gwvpmini_goSetup();\r
+       return;\r
+}\r
+\r
+// need to make this db agnostic\r
+if(!gwvpmini_DBExists($db_name)) {\r
+       if(!is_dir("$data_directory/repos")) mkdir("$data_directory/repos");\r
+\r
+       error_log("CREATEDATABASE");\r
+       gwvpmini_dbCreateSQLiteStructure($db_name);\r
+       gwvpmini_setConfigVal("repodir", "$data_directory/repos");\r
+}\r
+
+
+$nrepos = 50;
+$nusers = 100;
+
+if(isset($_REQUEST["GO"])) {
+       for($i = 0; $i < $nusers; $i++) {
+               $username = randomStr(rand(6,12));
+               $password = "Asdf";
+               $fullname = "asdf";
+               $email = "Aasdf@asdf";
+               $desc = "asdf";
+               $level = 1;
+               $status = 0;
+               $uid = gwvpmini_AddUser($username, $password, $fullname, $email, $desc, $level, $status);
+               echo "Created user, $username with uid of $uid<br>";
+       }
+       
+       for($i = 0; $i < $nrepos; $i++) {
+               $reponame = randomStr(rand(6,12));
+               $repodesc = "desc";
+               $uid = rand(10,$nusers-1);
+               gwvpmini_createGitRepo($reponame, $uid, $repodesc);
+               echo "Created repo, $reponame owned by $uid as $repodesc<br>";
+       }
+} else {
+       echo "click <a href=\"?GO=GO\">Go</a> to populate";
+}
+
+function randomStr($len)
+{
+       $strl = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+       
+       $retval = "";
+       for($i=0; $i<$len; $i++) {
+               $retval .= $strl[rand(0,strlen($strl)-1)];
+       }
+       
+       return $retval;
+}
+?>
\ No newline at end of file