[LON-CAPA-cvs] cvs: loncom /metadata_database lonmetadata_test.pl

matthew lon-capa-cvs@mail.lon-capa.org
Thu, 08 Apr 2004 14:51:19 -0000


matthew		Thu Apr  8 10:51:19 2004 EDT

  Modified files:              
    /loncom/metadata_database	lonmetadata_test.pl 
  Log:
  Modified &insert_test to pass in a table name to lonmetadata::store_metadata.
  
  
Index: loncom/metadata_database/lonmetadata_test.pl
diff -u loncom/metadata_database/lonmetadata_test.pl:1.3 loncom/metadata_database/lonmetadata_test.pl:1.4
--- loncom/metadata_database/lonmetadata_test.pl:1.3	Mon Jan 12 16:56:32 2004
+++ loncom/metadata_database/lonmetadata_test.pl	Thu Apr  8 10:51:19 2004
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 # The LearningOnline Network with CAPA
 #
-# $Id: lonmetadata_test.pl,v 1.3 2004/01/12 21:56:32 matthew Exp $
+# $Id: lonmetadata_test.pl,v 1.4 2004/04/08 14:51:19 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -107,6 +107,7 @@
 }
 
 sub test_inserts {
+    my $tablename = 'metadatatest';
     my $dbh = DBI->connect("DBI:mysql:lonmetatest","root",$supersecretpassword,
                            { RaiseError =>0,PrintError=>0});
     my @TestRecords = (
@@ -154,8 +155,22 @@
                         hostname =>'6',
                     },
                       );
+    # Create the table
+    my $request = &LONCAPA::lonmetadata::create_metadata_storage($tablename);
+    $dbh->do($request);
+    if ($dbh->err) {
+        $dbh->disconnect();
+        warn "Unable to create table for test";
+        return 0;
+    } else {
+        $dbh->disconnect();
+        return 1;
+    }
+    # Store the sample records
     foreach my $data (@TestRecords) {
-        my ($count,$error) = &LONCAPA::lonmetadata::store_metadata($dbh,$data);
+        my ($count,$error) = &LONCAPA::lonmetadata::store_metadata($dbh,
+                                                                   $tablename,
+                                                                   $data);
         if (! $count) {
             warn $error;
             return 0;