[GH-ISSUE #1809] [ENHANCEMENT] Add more tests to avoid regressions #1032

Closed
opened 2026-04-12 10:45:25 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @rgaidot on GitHub (Jan 5, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/1809

Originally assigned to: @pdevine on GitHub.

For example on this file https://github.com/jmorganca/ollama/blob/main/parser/parser.go

Warning: I did not validate my code, I did it blind.

package main

import (
    "strings"
    "testing"
)

func TestParser(t *testing.T) {
    input :=
    `
      FROM model1
      ADAPTER adapter1
      LICENSE MIT
      PARAMETER param1 value1
      PARAMETER param2 value2
      TEMPLATE template1
    `

    reader := strings.NewReader(input)

    commands, err := Parse(reader)

    if err != nil {
        t.Errorf("Error parsing commands: %v", err)
    }

    expectedCommands := []Command{
        {Name: "model", Args: "model1"},
        {Name: "adapter", Args: "adapter1"},
        {Name: "license", Args: "MIT"},
        {Name: "parameter", Args: "param1 value1"},
        {Name: "parameter", Args: "param2 value2"},
        {Name: "template", Args: "template1"},
    }

    if !compareCommands(commands, expectedCommands) {
        t.Errorf("Parsed commands do not match expected commands.")
    }
}
Originally created by @rgaidot on GitHub (Jan 5, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/1809 Originally assigned to: @pdevine on GitHub. For example on this file https://github.com/jmorganca/ollama/blob/main/parser/parser.go _Warning: I did not validate my code, I did it blind._ ```go package main import ( "strings" "testing" ) func TestParser(t *testing.T) { input := ` FROM model1 ADAPTER adapter1 LICENSE MIT PARAMETER param1 value1 PARAMETER param2 value2 TEMPLATE template1 ` reader := strings.NewReader(input) commands, err := Parse(reader) if err != nil { t.Errorf("Error parsing commands: %v", err) } expectedCommands := []Command{ {Name: "model", Args: "model1"}, {Name: "adapter", Args: "adapter1"}, {Name: "license", Args: "MIT"}, {Name: "parameter", Args: "param1 value1"}, {Name: "parameter", Args: "param2 value2"}, {Name: "template", Args: "template1"}, } if !compareCommands(commands, expectedCommands) { t.Errorf("Parsed commands do not match expected commands.") } } ```
Author
Owner

@pdevine commented on GitHub (Jan 5, 2024):

@rgaidot we definitely need more unit tests. We've been slowly adding them, but there's still a lot of missing coverage. I went ahead and took your suggestion and filled it out a little more. Thanks for suggesting this!

<!-- gh-comment-id:1879261692 --> @pdevine commented on GitHub (Jan 5, 2024): @rgaidot we definitely need more unit tests. We've been slowly adding them, but there's still a lot of missing coverage. I went ahead and took your suggestion and filled it out a little more. Thanks for suggesting this!
Author
Owner

@pdevine commented on GitHub (Jan 5, 2024):

I'm going to go ahead and close the issue for now. Feel free to reopen it if there's something specific you think is missing tests. As I mentioned in the previous comment we've been adding more unit tests, and we've been looking to add functional/regression tests as well.

<!-- gh-comment-id:1879312678 --> @pdevine commented on GitHub (Jan 5, 2024): I'm going to go ahead and close the issue for now. Feel free to reopen it if there's something specific you think is missing tests. As I mentioned in the previous comment we've been adding more unit tests, and we've been looking to add functional/regression tests as well.
Author
Owner

@rgaidot commented on GitHub (Jan 6, 2024):

Parser was just one example. but I thank you for considering this issue.
Best

<!-- gh-comment-id:1879655008 --> @rgaidot commented on GitHub (Jan 6, 2024): Parser was just one example. but I thank you for considering this issue. Best
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#1032