diff --git a/common/database.go b/common/database.go index 8aca39f..eca4801 100644 --- a/common/database.go +++ b/common/database.go @@ -184,6 +184,10 @@ func DummyPopulateDB(test_db *gorm.DB) { checkErr(test_db.Model(&smo_A).Association("OutputMapping").Append(&outSig_A).Error) checkErr(test_db.Model(&smo_A).Association("OutputMapping").Append(&outSig_B).Error) + //SimulationModel HM Files + checkErr(test_db.Model(&smo_A).Association("Files").Append(&file_A).Error) + checkErr(test_db.Model(&smo_A).Association("Files").Append(&file_B).Error) + // Visualization BT User checkErr(test_db.Model(&vis_A).Association("User").Append(&usr_A).Error) diff --git a/common/database_test.go b/common/database_test.go index 50bff26..49cd261 100644 --- a/common/database_test.go +++ b/common/database_test.go @@ -38,6 +38,7 @@ func TestDummyDBAssociations(t *testing.T) { var sigs []Signal var smos []SimulationModel var files []File + var files_sm []File var projs []Project var simns []Simulation var viss []Visualization @@ -62,6 +63,12 @@ func TestDummyDBAssociations(t *testing.T) { "Expected to have %v Output AND Input Signals. Has %v.", 4, len(sigs)) } + a.NoError(db.Model(&smo).Related(&files_sm, "Files").Error) + if len(files_sm) != 2 { + a.Fail("Simulation Model Associations", + "Expected to have %v Files. Has %v.", 2, len(files_sm)) + } + // Simulation a.NoError(db.Find(&simn, 1).Error, fM("Simulation")) diff --git a/common/datastructs.go b/common/datastructs.go index 6d4dd9c..34c450d 100644 --- a/common/datastructs.go +++ b/common/datastructs.go @@ -75,6 +75,8 @@ type SimulationModel struct { BelongsToSimulator Simulator `gorm:"not null;association_autoupdate:false"` BelongsToSimulatorID uint `gorm:"not null"` + //new in villasweb 2.0 + Files []File `gorm:"association_autoupdate:false"` // NOTE: order of signals is important OutputMapping []Signal `gorm:""`