MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestScoreCalculation

Function TestScoreCalculation

pkg/advisor/optimizer_test.go:770–818  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Score and Complexity tests ---------------------------------------------------------------------------

(t *testing.T)

Source from the content-addressed store, hash-verified

768// ---------------------------------------------------------------------------
769
770func TestScoreCalculation(t *testing.T) {
771 t.Run("perfect score for no suggestions", func(t *testing.T) {
772 score := calculateScore(nil)
773 if score != 100 {
774 t.Errorf("expected 100, got %d", score)
775 }
776 })
777
778 t.Run("error reduces score by 20", func(t *testing.T) {
779 suggestions := []Suggestion{
780 {Severity: SeverityError},
781 }
782 score := calculateScore(suggestions)
783 if score != 80 {
784 t.Errorf("expected 80, got %d", score)
785 }
786 })
787
788 t.Run("warning reduces score by 10", func(t *testing.T) {
789 suggestions := []Suggestion{
790 {Severity: SeverityWarning},
791 }
792 score := calculateScore(suggestions)
793 if score != 90 {
794 t.Errorf("expected 90, got %d", score)
795 }
796 })
797
798 t.Run("info reduces score by 5", func(t *testing.T) {
799 suggestions := []Suggestion{
800 {Severity: SeverityInfo},
801 }
802 score := calculateScore(suggestions)
803 if score != 95 {
804 t.Errorf("expected 95, got %d", score)
805 }
806 })
807
808 t.Run("score does not go below 0", func(t *testing.T) {
809 suggestions := make([]Suggestion, 10)
810 for i := range suggestions {
811 suggestions[i].Severity = SeverityError
812 }
813 score := calculateScore(suggestions)
814 if score != 0 {
815 t.Errorf("expected 0, got %d", score)
816 }
817 })
818}
819
820func TestComplexityClassification(t *testing.T) {
821 t.Run("nil AST is simple", func(t *testing.T) {

Callers

nothing calls this directly

Calls 3

calculateScoreFunction · 0.85
RunMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected