Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 5 of 5 for AssertAssociationCount (0.5 sec)

  1. tests/associations_belongs_to_test.go

    	user.ManagerID = &manager2.ID
    	CheckUser(t, user2, user)
    
    	AssertAssociationCount(t, user2, "Company", 1, "AfterReplace")
    	AssertAssociationCount(t, user2, "Manager", 1, "AfterReplace")
    
    	// Delete
    	if err := DB.Model(&user2).Association("Company").Delete(&Company{}); err != nil {
    		t.Fatalf("Error happened when delete Company, got %v", err)
    	}
    	AssertAssociationCount(t, user2, "Company", 1, "after delete non-existing data")
    
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Mon Oct 30 09:15:49 UTC 2023
    - 9.3K bytes
    - Viewed (0)
  2. tests/associations_many2many_test.go

    	}
    
    	user.Languages = []Language{language2}
    	CheckUser(t, user2, user)
    
    	AssertAssociationCount(t, user2, "Languages", 1, "AfterReplace")
    
    	// Delete
    	if err := DB.Model(&user2).Association("Languages").Delete(&Language{}); err != nil {
    		t.Fatalf("Error happened when delete language, got %v", err)
    	}
    	AssertAssociationCount(t, user2, "Languages", 1, "after delete non-existing data")
    
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Sat Jun 10 13:05:19 UTC 2023
    - 13.2K bytes
    - Viewed (0)
  3. tests/associations_has_many_test.go

    	}
    
    	user.Pets = []*Pet{&pet2}
    	CheckUser(t, user2, user)
    
    	AssertAssociationCount(t, user2, "Pets", 1, "AfterReplace")
    
    	// Delete
    	if err := DB.Model(&user2).Association("Pets").Delete(&Pet{}); err != nil {
    		t.Fatalf("Error happened when delete pet, got %v", err)
    	}
    	AssertAssociationCount(t, user2, "Pets", 1, "after delete non-existing data")
    
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Wed Jun 12 10:49:45 UTC 2024
    - 16K bytes
    - Viewed (0)
  4. tests/associations_has_one_test.go

    	}
    
    	user.Account = account2
    	CheckUser(t, user2, user)
    
    	AssertAssociationCount(t, user2, "Account", 1, "AfterReplace")
    
    	// Delete
    	if err := DB.Model(&user2).Association("Account").Delete(&Account{}); err != nil {
    		t.Fatalf("Error happened when delete account, got %v", err)
    	}
    	AssertAssociationCount(t, user2, "Account", 1, "after delete non-existing data")
    
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Wed Jun 12 10:49:45 UTC 2024
    - 7.1K bytes
    - Viewed (0)
  5. tests/associations_test.go

    package tests_test
    
    import (
    	"testing"
    
    	"gorm.io/gorm"
    	"gorm.io/gorm/clause"
    	"gorm.io/gorm/schema"
    	. "gorm.io/gorm/utils/tests"
    )
    
    func AssertAssociationCount(t *testing.T, data interface{}, name string, result int64, reason string) {
    	if count := DB.Model(data).Association(name).Count(); count != result {
    		t.Fatalf("invalid %v count %v, expects: %v got %v", name, reason, result, count)
    	}
    
    	var newUser User
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Wed Feb 08 08:29:09 UTC 2023
    - 10.9K bytes
    - Viewed (0)
Back to top