1616package lib_test
1717
1818import (
19+ "crypto/sha256"
20+ "encoding/hex"
1921 "encoding/json"
2022 "fmt"
2123 "io"
@@ -687,6 +689,7 @@ func TestInstallWithGitUrlFragmentAsBranch(t *testing.T) {
687689
688690 t .Run ("RefPointingToBranch" , func (t * testing.T ) {
689691 libInstallDir := cli .SketchbookDir ().Join ("libraries" , "ArduinoCloud" )
692+ t .Cleanup (func () { libInstallDir .RemoveAll () })
690693
691694 // Verify install with ref pointing to a branch
692695 require .NoDirExists (t , libInstallDir .String ())
@@ -700,6 +703,24 @@ func TestInstallWithGitUrlFragmentAsBranch(t *testing.T) {
700703 require .NoError (t , err )
701704 require .Contains (t , string (fileToTest ), `#define LENGHT_M "meters"` ) // nolint:misspell
702705 })
706+
707+ t .Run ("RefPointingToHash" , func (t * testing.T ) {
708+ libInstallDir := cli .SketchbookDir ().Join ("libraries" , "ArduinoCloud" )
709+ t .Cleanup (func () { libInstallDir .RemoveAll () })
710+
711+ // Verify install with ref pointing to a branch
712+ require .NoDirExists (t , libInstallDir .String ())
713+ _ , _ , err = cli .Run ("lib" , "install" , "--git-url" , "https://github.com/arduino-libraries/ArduinoCloud.git#fe1a1c5d1f8ea2cb27ece1a3b9344dc1eaed60b6" , "--config-file" , "arduino-cli.yaml" )
714+ require .NoError (t , err )
715+ require .DirExists (t , libInstallDir .String ())
716+
717+ // Verify that the correct branch is checked out
718+ // https://github.com/arduino-libraries/ArduinoCloud/commit/fe1a1c5d1f8ea2cb27ece1a3b9344dc1eaed60b6
719+ fileToTest , err := libInstallDir .Join ("examples" , "ReadAndWrite" , "ReadAndWrite.ino" ).ReadFile ()
720+ require .NoError (t , err )
721+ chksum := sha256 .Sum256 (fileToTest )
722+ require .Equal (t , hex .EncodeToString (chksum [:]), `f71889cd6da3b91755c7d1b8ec76b7ee6e2824d8a417c043d117ffdf1546f896` )
723+ })
703724}
704725
705726func TestUpdateIndex (t * testing.T ) {
0 commit comments