File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -700,3 +700,40 @@ func TestQueryer(t *testing.T) {
700
700
}
701
701
}
702
702
}
703
+
704
+ func TestStress (t * testing.T ) {
705
+ tempFilename := TempFilename ()
706
+ db , err := sql .Open ("sqlite3" , tempFilename )
707
+ if err != nil {
708
+ t .Fatal ("Failed to open database:" , err )
709
+ }
710
+ db .Exec ("CREATE TABLE foo (id int);" )
711
+ db .Exec ("INSERT INTO foo VALUES(1);" )
712
+ db .Exec ("INSERT INTO foo VALUES(2);" )
713
+ db .Close ()
714
+
715
+ for i := 0 ; i < 10000 ; i ++ {
716
+ db , err := sql .Open ("sqlite3" , tempFilename )
717
+ if err != nil {
718
+ t .Fatal ("Failed to open database:" , err )
719
+ }
720
+
721
+ for j := 0 ; j < 3 ; j ++ {
722
+ rows , err := db .Query ("select * from foo where id=1;" )
723
+ if err != nil {
724
+ t .Error ("Failed to call db.Query:" , err )
725
+ }
726
+ for rows .Next () {
727
+ var i int
728
+ if err := rows .Scan (& i ); err != nil {
729
+ t .Errorf ("Scan failed: %v\n " , err )
730
+ }
731
+ }
732
+ if err := rows .Err (); err != nil {
733
+ t .Errorf ("Post-scan failed: %v\n " , err )
734
+ }
735
+ rows .Close ()
736
+ }
737
+ db .Close ()
738
+ }
739
+ }
You can’t perform that action at this time.
0 commit comments